Created
April 28, 2011 00:15
-
-
Save jpablo/945532 to your computer and use it in GitHub Desktop.
Partial function application with javascript
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
/* | |
* taken from | |
* http://www.webreference.com/programming/javascript/rg17/ | |
* */ | |
Function.prototype.partial = function () { | |
var method = this; | |
var args = Array.prototype.slice.call(arguments); | |
return function() { | |
var allArguments = args.concat(Array.prototype.slice.call(arguments)); | |
return method.apply(this, allArguments); | |
}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment