-
-
Save fermion/475816 to your computer and use it in GitHub Desktop.
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
// Code | |
Function.prototype.curry = function() { | |
var func = this, a = Array.prototype.slice.call(arguments, 0); | |
return function() { | |
var a_len = a.length, length = arguments.length; | |
while (length--) a[a_len + length] = arguments[length]; | |
return func.apply(this, a); | |
} | |
}; | |
// Example 01 | |
function xy(x, y) { return x+y; } | |
var x = xy.curry(7); | |
x(3); // 10 | |
// Example 02 | |
var warn = alert.curry("Warning!"); | |
warn(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment