ES5的新增方法
1. 数组方法:
迭代(遍历)方法:forEach,map,filter,some,every
(1)forEach,map相似,与以前的each遍历相似,不会终止迭代arry.forEach(function(currentValue,index,arr))
currentValue:数组当前项的值
index:数组当前项的索引
arr:数组对象本身
//forEach迭代(遍历)数组
var arr = [1, 2, 3];
var sum = 0;
arr.forEach(function(value, index, array) {
console.log("每个数组元素" + value);
console.log("每个数组元素的索引号" + index);
console.log("数组本身" + array);
sum += value; //求数组元素的和
console.log(s