Created

Embed URL

HTTPS clone URL

SSH clone URL

You can clone with HTTPS or SSH.

Download Gist

Cost of using 'var self = this;'

View gist:9974951
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
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.