Created
August 11, 2011 06:18
-
-
Save cdleary/1139011 to your computer and use it in GitHub Desktop.
Rebinding proposal for JS
This file contains hidden or 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.bind = function(thisVal) { | |
| var func = this.__orig__ || this; | |
| var bound = function() { | |
| return func.apply(thisVal, arguments); | |
| }; | |
| bound.__orig__ = func; | |
| return bound; | |
| }; | |
| var f = function() { return this; } | |
| print(f.bind(12)()); | |
| print(f.bind(12).bind(13)()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment