reduce() var arr = [1,2,3,4,5,6] var a = arr.reduce(function(total,cur){ //total初始值,计算结果后的返回值 cur当前元素 return total+cur },0); //0 初始化值 //es6写法 var a = arr.reduce((total,cur)=>total+cur,0)