November 2017
Intermediate to advanced
386 pages
9h 22m
English
The idea of currying, by itself, is simple. If you need a function with, say, three parameters, instead of writing (with arrow functions) something like the following:
const make3 = (a, b, c) => String(100 * a + 10 * b + c);
You can have a sequence of functions, each with a single parameter:
const make3curried = a => b => c => String(100 * a + 10 * b + c);
Alternatively, you might want to consider them to be nested functions:
const make3curried2 = function(a) { return function(b) { return function(c) { return String(100 * a + 10 * b + c); }; };};
In terms of usage, there's an important difference in how you'd use each function. While you would call the first in usual fashion, such as make3(1,2,4), that wouldn't ...