Created
October 29, 2011 00:03
-
-
Save seanmonstar/1323877 to your computer and use it in GitHub Desktop.
If you use `var self = this`, die.
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 Example = new Class({ | |
initialize: function() { | |
// i now hate you if you do this in my codez | |
var self = this; // or that. | |
// 10 or 20 lines down, in another closure, I have to read up to | |
// make sure `self` is set the `this` that I want | |
// instead, this is they way to go | |
var example = this; | |
// i know what `example` is, because we're in the Example class | |
myEl.addEvent('click', function() { | |
example.derp(); | |
}); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment