我尝试过拼接、连接、应用、调用等。
我想做的就是采用这样的数组:
[["alksjdflskdj","2","1.33","1.30","", "5","1","1","1","1","1","0","","Other notes"],
["test","1","","","","1","0","1","0","0","0","",""],
["test3","","","","","","0","0","0","0","0","",""],
["","","","","","","0","0","0","0","0","",""],
["","","","","","","0","0","0","0","0","",""]]
并在上面的数组中添加类似的内容:
["2018-03-06 04:14:59", "T", "", "", "0"]
最终结果如下所示:
[["alksjdflskdj","2","1.33","1.30","", "5","1","1","1","1","1","0","","Other notes"],
["test","1","","","","1","0","1","0","0","0","",""],
["test3","","","","","","0","0","0","0","0","",""],
["","","","","","","0","0","0","0","0","",""],
["","","","","","","0","0","0","0","0","",""],
["2018-03-06 04:14:59", "T", "", "", "0"]]
提前致谢。这让我很困惑。
最佳答案
您可以使用push()
正如其他人已经提到的,为了将元素添加到现有数组:
arr1.push(ele); // arr1 now has ele at last index
您可以使用concat()
,它不会改变原始数组并返回一个全新的数组:
var arr2 = arr1.concat(ele) // arr1 remains the same and arr2 has arr1 with ele at las index
这取决于您的需求。
关于javascript - 将数组插入数组的数组中 Javascript,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49123467/