), length - args.length)
}
}
const add = currying(function(a, b, c) {
console.log([a, b, c].reduce...详情看我之前写的文章 js 高阶函数之柯里化
map、reduce、filter
此三种函数均为高阶函数,如何实现这三个函数,接下来看看。...}
Array.prototype.map = map;
[1, 2, 3].map(ele => `#${ele}#`)
// myself
// ["#1#", "#2#", "#3#"]
reduce...实现
高阶函数 reduce 将一个数组中的元素精简为单一的值,该值是由每个元素与一个累计值通过一个函数计算得出的
function reduce(fn, accumulator) {
let...= reduce;
[1, 2, 3].reduce((n, p) => n + p)
// myself
// 6
// 也可以指定第一个累计值
[1, 2, 3].reduce((n, p) =