Live data from Hacker News

A book series on JavaScript

github.com

41–50 of 111 posts

Re: A book series on JavaScript

#41
post #22
post #10

Earlier quoted context omitted.

It's just one chapter and the rest of the book is about prototypes and inheritance. It's also not just 'the stuff on the left side of the dot'. using strict mode, call/apply, the new keyword and arrow functions have influence on what `this` is. And they are applied in a certain order of precedence you need to know.

I found it pedantic as well. 'This' really is just the object to the left of the dot, unless 'new' is used to invoke the function with a brand new 'this' object. Functions called without a 'left-of-the-dot' argument, not having a 'this' injected, just see that of the global scope (Window). Call and apply allow to explicitly inject the 'this' object. That pretty much sums up at least 80% of the chapter.

As kabes pointed out above, there are more exceptions than the ones you mention. Don't forget bind, call/apply, strict mode, and arrow functions.

"this" is just a reference to the function context. Function context has a strong definition in programming languages. Saying that it's the stuff to the "left-of-dot" modulo a bunch of exceptions is sort of missing the forest for the trees, in my opinion.

Left-of-dot is a great way to introduce the concept but function context is so much more than just that.

Re: A book series on JavaScript

#42
post #40
post #33

Earlier quoted context omitted.

I fully agree, those books are awesome if you want to truly understand JS. I would, however, not say that understanding JS will help you become a better programmer and the time invested in fully understanding JS might be better invested somewhere else. Some parts of "understanding JS" is just understanding a (insert your swearword) designed language, unfortunately. You might just not fully understand those parts and…

That's why I would recommend to read also "JavaScript: The Good Parts" (book, 2008) by Douglas Crockford. It covers (what is nowadays known as Javascript 1.5) and highlights the good parts of the language.

Actually, Simpson in his "you don't know JS" series of books makes a statement against "Javascript: the good parts". The main argument is that it's actually "Javascript: the easy parts". So crockford basically says "Just don't use the things most people find confusing when starting with JS". Instead, Simpson argues it's better to understand the language thoroughly so you can use all of its features to your advantage.

Re: A book series on JavaScript

#44
post #42
post #40

Earlier quoted context omitted.

That's why I would recommend to read also "JavaScript: The Good Parts" (book, 2008) by Douglas Crockford. It covers (what is nowadays known as Javascript 1.5) and highlights the good parts of the language.

Actually, Simpson in his "you don't know JS" series of books makes a statement against "Javascript: the good parts". The main argument is that it's actually "Javascript: the easy parts". So crockford basically says "Just don't use the things most people find confusing when starting with JS". Instead, Simpson argues it's better to understand the language thoroughly so you can use all of its features to your advantage.

I believe the truth lies somewhere in between. You will have a really rough time programming JS with the good parts only, but you will also have a rough time annoying your colleagues when you are the only one using "this" in a place where it's considered a bug by most people.

Re: A book series on JavaScript

#45

I really don't get the arrogant "You don't know X". Maybe I know it, maybe I don't know it. But if I know it already, then I am wasting my time since I think I don't know it (not really). However if I don't know it, then the condescending tone doesn't really motivate me to want to know (while I love to learn about Javascript).

I do think it is meant to be a catchy marketing play on "You Don't Know X" but the author also describes it as a reference to the fact that "knowing" JavaScript can only ever be temporal:

No matter how much you feel you've mastered JavaScript to this point, the truth is that JavaScript is never going to stop evolving, and moreover, the rate of evolution is increasing rapidly. This fact is almost a metaphor for the spirit of this series, to embrace that we'll never fully know every part of JS, because as soon as you master it all, there's going to be new stuff coming down the line that you'll need to learn.[1]

[1] From Ch. 3 "Into YDKJS" of the first book Up & Going: https://github.com/getify/You-Dont-Know-JS/blob/master/up%20...

Re: A book series on JavaScript

#46
I've met with Kyle Simpson a couple of times. He develops a lot of our coursework at Makersquare/Hack Reactor. Definitely a sharp guy and very down to earth. His code can be above my head but he's really good at bringing it back down to a level the students can understand, which as a former teacher I think is even more difficult that getting to an expert level in the first place.

Re: A book series on JavaScript

#47
post #40
post #33

Earlier quoted context omitted.

I fully agree, those books are awesome if you want to truly understand JS. I would, however, not say that understanding JS will help you become a better programmer and the time invested in fully understanding JS might be better invested somewhere else. Some parts of "understanding JS" is just understanding a (insert your swearword) designed language, unfortunately. You might just not fully understand those parts and…

That's why I would recommend to read also "JavaScript: The Good Parts" (book, 2008) by Douglas Crockford. It covers (what is nowadays known as Javascript 1.5) and highlights the good parts of the language.

I think "JavaScript: The Good Parts" is outdated now, in particular the way it advocates handling object-oriented programming and inheritance with a "roll your own" method. It was great for its time, but especially with the advent of ES2015, modern JavaScript is going in a different direction.

Re: A book series on JavaScript

#50
post #47
post #40

Earlier quoted context omitted.

That's why I would recommend to read also "JavaScript: The Good Parts" (book, 2008) by Douglas Crockford. It covers (what is nowadays known as Javascript 1.5) and highlights the good parts of the language.

I think "JavaScript: The Good Parts" is outdated now, in particular the way it advocates handling object-oriented programming and inheritance with a "roll your own" method. It was great for its time, but especially with the advent of ES2015, modern JavaScript is going in a different direction.

My point was, it's not outdated. Javascript 2016 just got new featured that oviously aren't covered. The class syntax is just a syntactic sugar and it's important to understand how it's working under the hood. JS has prototype based inheritance, which is more powerful and flexible than class based inheritance. JS is therefor different to grasp than Java and C#. There are still many coding JS and don't get it.
Post reply on HN