I'm reading about Function currying in Javascript. I got the concept and the examples were easy to understand.
But then, the author of the article says that currying a function too much can be messy as for the multiple nested returns, and shows a function to curry another function passed as argument.
var curryIt = function(uncurried) {
var parameters = Array.prototype.slice.call(arguments, 1);
return function() {
return uncurried.apply(this, parameters.concat(
Array.prototype.slice.call(arguments, 0)
));
};
};
Then applies it this way
var greeter = function(greeting, separator, emphasis, name) {
console.log(greeting + separator + name + emphasis);
};
var greetHello = curryIt(greeter, "Hello", ", ", ".");
greetHello("Heidi"); //"Hello, Heidi."
greetHello("Eddie"); //"Hello, Eddie."
curryIt is the function that curries another function. How exactly is doing that?
Though there is no unfamiliar code to me I seem not to get it.