-
Notifications
You must be signed in to change notification settings - Fork 215
Open
Description
建议修改成:
const currying = function (fn, ...args) {
const len = fn.length;
args = args || [];
return (...arguments) => {
const totalArgs = [...args].concat([...arguments]);
return totalArgs.length >= len
? fn.call(this, ...totalArgs)
: currying.call(this, fn, ...totalArgs);
};
};
const sum = (a, b, c) => a + b + c;
const newSum = currying(sum);
const res = newSum(1)(2)(3) // 6
console.log(res); Metadata
Metadata
Assignees
Labels
No labels

