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
上次在手写call等文章中看到了,支持柯里化,所以简单的了解下(只做了解)
只传递给函数一部分参数来调用它,让它返回一个函数去处理剩下的参数。
function curry(fn) { var args = Array.prototype.slice.call(arguments, 1) return function () { var innerArgs = Array.prototype.slice.call(arguments) var finalArgs = args.concat(innerArgs) return fn.apply(null, finalArgs) } } function add(num1, num2) { return num1 + num2 } var curriedAdd = curry(add, 5) console.log(curriedAdd(3)) //8
《JavaScript高级程序设计(第3版)》
The text was updated successfully, but these errors were encountered:
No branches or pull requests
柯里化
前言
上次在手写call等文章中看到了,支持柯里化,所以简单的了解下(只做了解)
通俗解释
只传递给函数一部分参数来调用它,让它返回一个函数去处理剩下的参数。
例子
参考
《JavaScript高级程序设计(第3版)》
The text was updated successfully, but these errors were encountered: