HN2new | past | comments | ask | show | jobs | submitlogin

You could probably factor exceptions 1) and 3) into the rule too!

         foo();
1) What's left of a bare function call is nothing - except for a blank line that leads to the top indentation level. In other words, what's left of it is the global scope. So, 'this' refers to the implicit global object in your environment. (Alternatively, in strict mode, since nothing is to the left of the call, 'this' is bound to nothing.)

    new Foo();
3) To the left of this function call is the 'new' keyword. So, 'this' refers to the new object that was just created for the constructor.


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

Search: