‘this’ in function, and in object

this is not part of the closure scope, it can be thought of as an additional parameter to the function that is bound at the call site.

If the method is not called as a method then the global object is passed as this. In the browser, the global object is identical to window. For example, consider the following funciton,

and the following object,

If you call the function using method syntax such as,

then this is bound to obj.

If you call someFunction() directly, such as,

then this is bound to the global object, that is window.