Skip to content

Instantly share code, notes, and snippets.

@warpgate3
Created November 29, 2017 09:59
Show Gist options
  • Save warpgate3/bb6388ae4bee90e15a5edfa4101de7f5 to your computer and use it in GitHub Desktop.
Save warpgate3/bb6388ae4bee90e15a5edfa4101de7f5 to your computer and use it in GitHub Desktop.
javascript currying
Function.prototype.curry = function() {
var slice = Array.prototype.slice;
var args = slice.apply(arguments);
console.dir(slice);
var that = this;
return function() {
return that.apply(null, args.concat(slice.apply(arguments)));
}
};
var sum = function(a, b) {
return a + b;
}
var s3 = sum.curry(3);
console.log(s3(10));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment