array.reduce(function(total, currentValue, currentIndex, arr), initialValue)
var num = [1,2,3,4,5];
var res = num.reduce(function(total,num){
return total+num;
},0);
console.log(res);//15
//num.reduce((total,num) => total += num, 0);
//没有初始值initialValue(即上面例子中的0),当数组为0时会抛出异常提示reduce函数没有初始值,所以为兼容性一般加上initialValue