Created
March 13, 2012 17:27
-
-
Save afshin/2030044 to your computer and use it in GitHub Desktop.
Partial Application in JavaScript Revisited 1
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.partial = function () { | |
var fn = this, args = Array.prototype.slice.call(arguments); | |
return function () { | |
var arg = 0; | |
for (var i = 0; i < args.length && arg < arguments.length; i++) | |
if (args[i] === undefined) | |
args[i] = arguments[arg++]; | |
return fn.apply(this, args); | |
}; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment