将0当做reduce回调函数中的初始值,然后依次累加

// 数组求和
var arr = [1, 2, 3, 4, 5]
var total = arr.reduce(function (prev, next) {
    return prev + next
}, 0)
console.log(total)
把最实用的经验,分享给最需要的读者,希望每一位来访的朋友都能有所收获!