November 2017
Intermediate to advanced
386 pages
9h 22m
English
Similar to what we did with currying, there's a simple way to do partial currying. We will take advantage of the fact that .bind() can actually fix many arguments at once:
const partialCurryingByBind = fn => fn.length === 0 ? fn() : (...pp) => partialCurryingByBind(fn.bind(null, ...pp));
Compare the code to the previous curryByBind() function and you'll see the very small differences:
const curryByBind = fn => fn.length === 0 ? fn() : p => curryByBind(fn.bind(null, p));
The mechanism is exactly the same. The only difference is that in our new function, we can bind many arguments at the same time, while in curryByBind() we always bind just one. We can revisit our earlier example -- and the only difference is ...
Read now
Unlock full access