Created
January 25, 2012 16:41
-
-
Save pthrasher/1677154 to your computer and use it in GitHub Desktop.
how to fix js inheritance and class scope issues
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
| var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }; | |
| function MyClass() { | |
| this.my_method = __bind(this.my_method, this); | |
| this.my_other_method = __bind(this.my_other_method, this); | |
| } | |
| MyClass.prototype.my_method = function(arg1) { | |
| return arg1; | |
| } | |
| MyClass.prototype.my_other_method = function(arg1) { | |
| return this.my_method(arg1); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment