我正在尝试将javascript中的2个数组合并为一个。
var lines = new Array("a","b","c");
lines = new Array("d","e","f");
这是一个简单的示例,我希望能够将它们组合起来,以便在读取第二行时,数组中的第4个元素将返回“ d”
我该怎么办?
var a = ['a','b','c'];
var b = ['d','e','f'];
var c = a.concat(b); //c is now an an array with: ['a','b','c','d','e','f']
console.log( c[3] ); //c[3] will be 'd'
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句