JavaScript:如何将两个数组连接/组合成一个数组?
我试图把2个数组合成一个。
var lines = new Array("a","b","c"); lines = new Array("d","e","f");
这是一个快速的例子,我想能够将它们结合起来,这样当第二行被读取时,数组中的第四个元素将返回“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'