reduce方法
garvin 12/3/2021 JsHooks
# 迭代MDN (opens new window)
- eg1
[0, 1, 2, 3, 4].reduce((accumulator, currentValue, currentIndex, array) => {
return accumulator + currentValue
}, 10)
1
2
3
2
3
[0, 1, 2, 3, 4].reduce((accumulator, currentValue, currentIndex, array) => {
return accumulator + currentValue
}, 10)