var a1; var a2; var a3; var b1; var b2; var b3; var i; a1 = [1,2,3]; b1 = [4,5,6]; for (i = 0; i < b1.length; i++) { a1.push(b1[i]); } console.log(a1); //-> [ 1, 2, 3, 4, 5, 6 ] a2 = [1,2,3]; b2 = [4,5,6]; console.log(a2.concat(b2)); //-> [ 1, 2, 3, 4, 5, 6 ] a3 = [1,2,3]; b3 = [4,5,6]; [].push.apply(a3, b3); console.log(a3); //-> [ 1, 2, 3, 4, 5, 6 ]
ES6
var a4; var b4; a4 = [1,2,3]; b4 = [4,5,6]; console.log([...a4, ...b4]); //-> [ 1, 2, 3, 4, 5, 6 ]