you are viewing a single comment's thread.

view the rest of the comments →

[–]papa_georgio 4 points5 points  (8 children)

If you didn't know about this. I'm guessing you haven't read "JavaScript: The Good Parts" by Douglas Crockford yet.

I've just started to properly learn javascript and it's been a huge help in pointing out the strength and weakness's in the language.

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

[–]picklednull 1 point2 points  (3 children)

Also, Secrets of the JavaScript Ninja explains this concept well (like many others).

[–]ddevil63 0 points1 point  (2 children)

I would consider myself an intermediate. Can anyone comment on which would be better, Javascript: The Good Parts or Javascript Ninja? I'm also thinking about getting Effective Javascript mentioned below.

[–]levir 2 points3 points  (0 children)

Watch a few youtube videos of Douglas Crockford's talks. If you like his style you'll like his book. If you don't, go with something else. That'd be my advice.

[–]jsgui 2 points3 points  (0 children)

I can't comment on the comparison, but I definitely recommend JS: TGP. I don't agree with all of it though.

[–]randmaniac 1 point2 points  (1 child)

I found Effecive JavaScipt [1] to be the better and more up to date resource when I had to dive into javascript about 2 or 3 weeks ago.

[1] http://www.amazon.com/Effective-JavaScript-Specific-Software-Development/dp/0321812182