js中的reduce方法
array.reduce(function(total, currentValue, currentIndex, arr), initialValue)
参数 | 描述 | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
function(total,currentValue, index,arr) | 必需。用于执行每个数组元素的函数。 函数参数:
|
||||||||||
initialValue | 可选。传递给函数的初始值 |
array.reduce(function(total, currentValue, currentIndex, arr), initialValue)
参数 | 描述 | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
function(total,currentValue, index,arr) | 必需。用于执行每个数组元素的函数。 函数参数:
|
||||||||||
initialValue | 可选。传递给函数的初始值 |