而栈中的项的插入(推入)和移除(弹出),只发生在一个位置——栈的顶部。ECMAScript为数组专门提供了push和pop方法..../推入两项 console.log(colors.shift());//取得第一项
ECMAScript还未数组提供了一个unshift()方法。...function (item, index, array) {
return item > 2;
});
console.log(result);//[ 3, 4, 5, 6, 7, 8, 9 ]
forEach...():对数组中的每一项运行给定函数,没有返回值
var numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0];
var result = numbers.forEach(function...,或者是提供的初始值(initialValue)
curValue: 数组中当前被处理的数组项
index: 当前数组项在数组中的索引值
array: 调用 reduce()方法的数组。