SOURCE

var colors = ["red", "blue"];

// push() 接受任意数量的参数,从数组末尾添加相应的数据项,并返回修改后的数组的长度
var len = colors.push("brown", "black");
console.log("Array: " + colors + "; length: " + len);
console.log("");

// pop() 从数组末尾移除最后一项,减少数组的长度值,并返回被移除的项
var item = colors.pop();
console.log(item);
console.log("Array: " + colors + "; length: " + colors.length);
console.log("");

// shift() 移除数组的第一个项,减少数组的长度值,并返回被移除的项
var item = colors.shift();
console.log(item);
console.log("Array: " + colors + "; length: " + colors.length);
console.log("");

// unshift() 从数组前端添加任意项,返回修改后数组的长度
var len = colors.unshift("red", "green");
console.log("Array: " + colors + "; length: " + len);
console 命令行工具 X clear

                    
>
console