1.unshift //向数组开头添加元素
2…length
3.push //向数组末尾添加元素
4.splice //删除后添加,可在任意位置添加元素
function fn(arr){
arr.unshift(-1,0);
return arr;
}
console.log(fn([1,2,3]));
2.
function fn(arr1){
arr1[arr1.length] = 1;
return arr1;
}
console.log(fn([1,2,3]));
3.
function fn(arr){
arr.push(1);
return arr;
}
console.log(fn([1,2,3]));
var array = [“1”, “3”, “4”];
array.splice(1, 0, “2”);
console.log(array);