Created
October 20, 2013 02:16
-
-
Save kgarfinkel/7064078 to your computer and use it in GitHub Desktop.
Javascript's 'apply' re-implemented.
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
var apply = function(fn, context) { | |
var args = Array.prototype.slice.call(arguments, 2), | |
result; | |
context.fn = fn; | |
result = context.fn(args); | |
delete this.fn; | |
return result; | |
}; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment