将0当做reduce回调函数中的初始值,然后依次累加
// 数组求和 var arr = [1, 2, 3, 4, 5] var total = arr.reduce(function (prev, next) { return prev + next }, 0) console.log(total)