Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

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-tha... has some more details.


Of course there are exceptions to the rule, but the rule should still be - avoid 'this.'




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: