-
-
Notifications
You must be signed in to change notification settings - Fork 865
Update functions.mdx #62
New issue
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
Conversation
made the partial execution/currying easy
if(ip.length < func.length) { | ||
return curry.bind(this, ...ip); | ||
} | ||
return func(...ip); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should this not be func.apply(this, ip);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As this function isn't called over any object and thus there is no requirement of holding the context (of this ref).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let sum = curryFunc(function () {
console.log(this)
});
sum.call(1);
I can see this fails without the proper implementation of this
}; | ||
function curryFunc(func) { | ||
return function curry(...ip) { | ||
if(ip.length < func.length) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we keep the func
as fn
and ip
as args
for consistency
made the partial execution/currying easy