3 ms·
because you sometimes want to refer to the original 'this' reference inside an inner nested function scope, where the actual 'this' keyword is rebound to the co
by shabble 14y ago
because you sometimes want to refer to the original 'this' reference inside an inner nested function scope, where the actual 'this' keyword is rebound to the context of the inner function.
function outer() {
var outer_this = this;
var inner = function() {
var inner_this = this;
// ...
}
}
http://stackoverflow.com/questions/4886632/what-does-var-that-this-mean-in-javascript http://stackoverflow.com/questions/4886632/what-does-var-tha... has some more details.
- pixie_ 14y agoOf course there are exceptions to the rule, but the rule should still be - avoid 'this.'