November 2017
Intermediate to advanced
386 pages
9h 22m
English
We can find a solution to currying by using the .bind() method. This allows us to fixate one argument (or more, if need be; we won't be needing that here, but later on, we will use it) and provide a function with that fixed argument. Of course, many libraries (such as Lodash, Underscore, Ramda, and more) provide this functionality, but we want to see how to implement that by ourselves.
Our implementation is quite short but will require some explanation:
const curryByBind = fn => fn.length === 0 ? fn() : p => curryByBind(fn.bind(null, ...