SOURCE

let arr = [1,2,3];
//1. push 在数组后面插入
arr.push(4); //1,2,3,4
console.log(arr);
arr.push(5,6); //1,2,3,4,5,6
console.log(arr);

//2. unshift在数组前面插入
arr = [1,2,3];
arr.unshift(4); //4,1,2,3
console.log(arr);
arr.unshift(5,6); //5,6,4,1,2,3
console.log(arr);


//3.splice
arr = [1,2,3];
arr.splice(1,0,'4'); //1,4,2,3
console.log(arr);
arr.splice(1,0,['5','6']); //1,5,6,4,2,3
console.log(arr);


//4. concat 连接数组
var a = [1,2,3];
var b = [4,5,6];
var c = a.concat(b);
console.log(c);
console 命令行工具 X clear

                    
>
console