Monday, March 02, 2009

Doug Crockford: JavaScript: The Good Parts

By Steve Souders, Member of Technical Staff

Doug Crockford, from "The Yahoo!" (his words), gave a talk at "The Google" (again, his words) last week. The talk is based on his recent book of the same name, JavaScript: The Good Parts. Doug is a, perhaps the, JavaScript guru who has undertaken responsibility for helping the world's web developers embrace JavaScript and use it successfully to build clean, fast web applications. He is the creator of JSLint, JSMin, and JSON. (Notice a theme?)

Doug was hitting on all cylinders. I've heard him deliver this talk before, but this rendition was off the scale in terms of clarity, humor, and takeaways. He flowed effortlessly from broad observations to detail-oriented code samples.

He begins with the observation that JavaScript is one of today's most used languages, so it obviously has gotten something right. Despite this success, JavaScript has plenty of bad parts: global variables, semicolon insertion, with and eval, and more. There's confusion with false values. Consider this example:
'' == 0
0 == '0'
'' != '0'
In JavaScript, all three of these statements return true. Doug highlights other traps that are easy to fall into using, ++, and typeof.

He delivers a clear, concise tutorial on object-oriented JavaScript and closures. The most satisfying piece to me was his clear explanation of why right-curlies ("block {" all on the same line) is the only acceptable style in JavaScript.

Tune in to the video below, and follow along with the presentation. It's enjoyable and enlightening. What a great combination. Thanks, Doug!


  1. I don't think of myself as a guru. I'm more of a mahatma.

  2. This comment has been removed by the author.

  3. thanks for the presentation mahatma :)

  4. Is it possible to use JSLint as JavaScript parser?

    I like lists of Globals, Functions, Closures, etc.

  5. I read your great book a while ago, Douglas. Thank you very much for writing it. I'm already looking forward to watching the video, although it's "based on a true story" ;-)

  6. Excellent presentation. Javascript is in an exciting stage. :)

  7. Hi Doug,

    Great presentation, thanks!. And great timing; I just finished your book, JavasScript: The Good Parts.

    I was trying to find a good JavaScript book for my dad, a graphic artist turned web designer. All of the other ones were like "Learn enough JavaScript in 5 seconds to steal cool thingamajigs from other sites". They were mostly a collection of useless, inconsistent, confusing, and frequently broken examples. None of them taught you the actual language.

    I bought your book for my dad because it was the thinnest, it focused on the syntax, and it did not once mention the DOM. I ended up reading it myself, mostly out of curiosity, and I was very impressed. I have to say you presented the JS syntax in a very clear and concise manner. You have really changed my opinion of JavaScript as well; I might actually consider using JS for something now.

    It's a great book and it should be required reading for anybody considering writing even one line of JavaScript.

  8. Thanks Doug, you cleared up a few things I was still questioning even after reading up what other people had to say, for some reason you made it click

  9. This presentation has made me decide to shelve my 5th edition of JavaScript the Definitive Guide, and instead hunger to get JavaScript the Good Parts. I also discovered the innumerable flaws of Yikes!