1,循环遍历
var a=[0,1]; var b=[2,3,4]; for(var i=0;i<b.length;i++){ a.push(b[i]) } console.log(a); //[0,1,2,3,4]
2,数组的concat 方法
var a = [101,102,103] var b = ['a','b','c'] var c = a.concat(b) //concat方法 返回新数组 console.log(c) //[101, 102, 103, "a", "b", "c"]
3,apply 方法
var a = [101,102,103] var b = ['a','b','c'] a.push.apply(a, b) //合并,不产生新数组 console.log(a) //[101, 102, 103, "a", "b", "c"]
4,ES6写法—— 扩展运算(...扩展运算符)
var a = [101,102,103] var b = ['a','b','c'] var c = [...a,...b] // 扩展运算符的方法 产生一个新数组
console.log(c) // [101, 102, 103, "a", "b", "c"]