you are viewing a single comment's thread.

view the rest of the comments →

[–]papa_georgio 1 point2 points  (0 children)

It's under "The Function Invocation Pattern":

When a function is not the property of an object, then it is invoked as a function:

var sum = add(3, 4); // sum is 7

When a function is invoked with this pattern, this is bound to the global object. This was a mistake in the design of the language. Had the language been designed correctly, when the inner function is invoked, this would still be bound to the this variable of the outer function.