Last summer I decided to take a more serious look at JavaScript in preparation for some work involving AngularJS. At the time, I regarded JavaScript as a poorly designed language used only by developers with no better option, but the undeniable rise of Node, NPM, Angular and so many other successful JavaScript frameworks had forced me to second guess my assumptions. Reluctantly, I decided to see what the JavaScript hype was all about.

Many years ago, as an intern programmer/analyst, I had read and enjoyed JavaScript: The Definitive Guide and initially planned to read it again to get back up to speed. I was not overly enthusiastic about it’s 1096 page and so was pleasantly surprised to discover that the most highly recommended book on the subject was JavaScript: The Good Parts by Douglas Crockford.

At only 176 pages, it would be easy to conclude that JavaScript: The Good Parts could not possibly do justice to a topic as mature and widespread as JavaScript; yet it does. Crockford explains it best in the very first section of the book.

“In JavaScript, there is a beautiful, elegant, highly expressive language that is buried under a steaming pile of good intentions and blunders. The best nature of JavaScript is so effectively hidden that for many years the prevailing opinion of JavaScript was that it was an unsightly, incompetent toy. My intention here is to expose the goodness in JavaScript, an outstanding, dynamic programming language. JavaScript is a block of marble, and I chip away the features that are not beautiful until the language’s true nature reveals itself. I believe that the elegant subset I carved out is vastly superior to the language as a whole, being more reliable, readable, and maintainable.”

This resonated with my own experience of the language. By eliminating the complexity of the “bad parts”, Crockford is able to present JavaScript in a way that allows the reader to quickly understand how to use the language effectively. No time is spent explaining the awful parts of JavaScript, except how to avoid them and why. Moreover, no time is spent discussing specific libraries or frameworks. Even the DOM is not addressed any more than what is absolutely necessary. This may leave some readers with unanswered questions, but Crockford is laser focused on the language itself and the book is better for it.

Although truly a masterpiece, my only humble criticism is that some of the explanations are arguably too terse and some of the code examples are more advanced than they need to be to illustrate the topic at hand. Do not expect multiple explanations for a single concept or any repetition at all. Expect a terse, no frills, right to the point, explanation with code samples heavily laced with functional-style programming. If that suites you (and it should), then you will enjoy this book.

In the terse spirit of the book, below are outlines of the good, awful, and bad parts, according to Crockford. Notice the proportions.

Good Parts

  • Functions as first class objects
  • Dynamic objects with prototypal inheritance
  • Object literals and array literals.

Awful parts

  • Global variables
  • Scope
  • Semicolon insertion
  • Reserved words
  • Unicode
  • typeof
  • parseInt
  • Floating Point
  • NaN
  • Phony Arrays
  • Falsy Values
  • hasOwnProperty
  • Object

Bad parts

  • ==
  • with Statement
  • eval
  • continue Statement
  • switch Fall Through
  • Block-less Statements
  • Bitwise Operators
  • The function Statement Versus the function Expresssion
  • Typed Wrappers
  • new
  • void

If you work with JavaScript in any capacity, I highly recommend reading this book!