function getSum(a, b, c) {
return a + b + c;
}
function curry(fn) {
return function curryFn(...args) {
console.log(fn.length);
if (args.length < fn.length) {
return function() {
console.log('arguments===', args.concat(Array.from(arguments)))
return curryFn(...args.concat(Array.from(arguments)));
}
}
return fn(...args);
}
}
let curryGetSum = curry(getSum);
console.log(curryGetSum(1, 2, 3));
console.log(curryGetSum(1)(2, 3));
console.log(curryGetSum(1)(2)(3));
网友评论