We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
这里的示例代码运行传参多一个,且不能达到预期效果。
建议修改成:
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);
运行结果:
The text was updated successfully, but these errors were encountered:
No branches or pull requests
这里的示例代码运行传参多一个,且不能达到预期效果。
建议修改成:
运行结果:
The text was updated successfully, but these errors were encountered: