//push 在数组后面加值
var colors=new Array("red","blue");
var len = colors.push("green","yellow","black");
console.log(len); //输出结果为5
console.log(colors); //输出结果为【"red","blue","green","yellow","black"】
// unshift,在数组前面加值
var nums=[2,7,8,6];
var size = nums.unshift(99,66,55);
console.log(nums); //输出结果为7
console.log(size); //输出结果为【2,7,8,6,99,66,55】
//pop 删除数组最后一个值
var n=nums.pop();
console.log(nums); //输出结果为[99, 66, 55, 2, 7, 8]
console.log(n); //输出结果为6 输出被删除的值
//shift 删除数组第一个值
var m = colors.shift();
console.log(m); //输出结果为red 输出被删除的值
console.log(colors); //输出结果为["blue", "green", "yellow", "black"]
来源:https://www.cnblogs.com/jian1234/p/9657441.html