Created
November 29, 2017 09:59
-
-
Save warpgate3/bb6388ae4bee90e15a5edfa4101de7f5 to your computer and use it in GitHub Desktop.
javascript currying
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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