forEach()方法可以遍历数组
使用方法:
var arr = [1,2,3];
var sum;
// forEach有一个回调函数,提供了三个参数,分别是 value , index , array
forEach(function(value, index, array) {
console.log("每个数组元素" + value);
console.log("数组的索引" + index);
console.log("数组本身" + array);
数组求和:
console.log( sum += value );
})