Skip to content

@dmathisen /gist:9974951
Created

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Cost of using 'var self = this;'
someNamespace = {
someVar1: '',
someVar2: '',
someEl: document.getElementById('el'),
someMethod: function() {
// do stuff
},
someOtherMethod: function() {
// do stuff
},
anotherMethod: function () {
var self = this;
this.someVar1 = 'whatever'; // is it more cost-effective to use self.someVar1 = 'whatever'???
this.someVar2 = 'whatever';
this.someMethod();
this.someEl.addEventListener("click", function() {
self.someOtherMethod();
}, false);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.