var colors=["red","green","blue"];
var colors2=colors.concat("yellow",["black","brown"]);
console.log(`colors:${colors}`);//["red","green","blue"]
console.log(`colors2:${colors2}`);//["red","green","blue",yellow","black","brown"]
var colors=["red","green","blue","black","brown"];
var colors2=colors.slice(1);
console.log(colors2);//["green","blue","black","brown"]
var colors3=colors.slice(1,4);
console.log(colors3);//["green","blue","black"]
var colors=["red","green","blue"];
var removed=colors.splice(0,1);//选中索引为1的项,以它为首删除1个项
console.log(removed);//["red"]
console.log(colors);//["green","blue"]
var colors=["red","green","blue"];
var removed=colors.splice(1,2);//选中索引为1的项,以它为首删除2个项
console.log(removed);//["green","blue"]
console.log(colors);//["red"]
var colors=["red","green","blue"];
var removed=colors.splice(1,1,"yellow","orange");
console.log(removed);//["green"]
console.log(colors);//["red","yellow","orange","blue"]
原文:https://www.cnblogs.com/Syinho/p/12397637.html