Working on Secrets of the JavaScript Ninja, I saw the curry function.
Function.prototype.curry = function() {
var fn = this, args = Array.prototype.slice.call(arguments);
return function() {
return fn.apply(this, args.concat(
Array.prototype.slice.call(arguments)));
};
};
Then I tried to use it by currying the split function (which inherited it through the Function.prototype.curry definition.
var splitIt = String.prototype.split.curry(/,\s*/); // split string into array
var results = splitIt("Mugan, Jin, Fuu");
console.log("results", results);
But [] prints out for the results. Why?
currydo? (I mean, besides giving flavor to the food XD)curryseems to be a poor name for the above function since it's a partially applied function.