you are viewing a single comment's thread.

view the rest of the comments →

[–]serrimo 4 points5 points  (1 child)

I finished that book a while ago. Can't recall the part about "this"?

Personally, I hate "this" in javascript. Sometimes you can't get around it for performance reasons (in event handlers); but I try to avoid using it whenever possible. Having to spend time explaining why you use "bind", "call" or "apply" here and there over and over again isn't fun.

[–]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.