嵌套数组 - 如何将一行元素添加到嵌套的 JavaScript 数组



我想添加行

['2008',777,333]

为了改变乐趣并保持结构:

var fun = [
['Year', 'Sales', 'Expenses'],
['2004',  1000,      400],
['2005',  1170,      460],
['2006',  660,       1120],
['2007',  1030,      540]
];

使用推送或连接似乎会破坏结构。 这能做到吗?

fun.push(['2008', "1033", "554"]) //to add whole row
fun[2].push('555') // to add item into row 3 as the last item

最新更新