Good JavaScript Reading, Part 1: Eloquent JavaScript

by Joey deVilla on June 2, 2011

eloquent javascript

If you decide to purchase only one JavaScript book, that book should be Marijn Haverbeke’s Eloquent JavaScript. There’s no greater recommendation than JavaScript creator Brendan Eich’s unsolicited review on Amazon:

A concise and balanced mix of principles and pragmatics. I loved the tutorial-style game-like program development. This book rekindled my earliest joys of programming. Plus, JavaScript!

An equally important recommendation comes from Shopify’s JavaScript guru, Nick Small, who points anyone who wants to get good at JavaScript to Eloquent JavaScript. Nick’s working on a very interesting JavaScript project (which I’ll write about in a future article) and he’s forgotten more about JavaScript than I’m likely to learn, so I give his JavaScript-related suggestions a lot of credence.

We’ve got a number of dead-tree copies of Eloquent JavaScript floating around Shopify, so I thumbed through one a couple of evenings ago and bought my own shortly afterwards. It’s that well written; my reading that night sold me on the book. I was initially rolling my eyes when I saw the title of the first chapter – Values, Variables and Control Flow – but Haverbeke’s got a gift for presenting things that you’ve seen before, shining a new light on them from an odd angle and giving you a new way of looking at stuff that is so familiar that you hadn’t given it much thought until now. And he does so in an informative, entertaining way, as evidenced by this passage on how to think of variables:

You should imagine variables as tentacles, rather than boxes. They do not contain values; they grasp them – two variables can refer to the same value. Only the values that the program still has a hold on can be accessed by it. When you need to remember something, you grow a tentacle to hold on to it, or you reattach one of your existing tentacles to a new value.

Haverbeke introduces the right stuff at the right time. After the basics, he presents functions, data structures and then error handling, providing a solid base of knowledge for the reader. With those out of the way, he goes on to cover functional programming, then object-oriented programming (most people would do it the other way around, but if you’re not getting into functional programming with JavaScript as soon as possible, you’re missing out on a lot of the power), then modules. After that, there’s a solid chapter on regular expressions and the book closes with four chapters on the most likely application of JavaScript: web development, from the DOM to browser events to what we once used to refer to as “Ajax”. At a svelte 200-ish pages, Eloquent JavaScript covers a lot of ground in less space than many other, lesser books you’ll find cluttering the shelves at your local store.

The only way to truly learn a programming language is to take it for a spin and as Seth Godin likes to put it, “poke the box”. Haverbeke made learning JavaScript from Eloquent JavaScript easier by providing an interactive JavaScript environment. There, you can run any of the examples from the book, make changes to them and see what the results are, and you can even experiment with your own original code.

Eloquent JavaScript is that rare sort of book that works for the person who’s just started programming, the experienced programmer who’s getting started with JavaScript and even the experienced JavaScript programmer who wants to get it right. If you code in JavaScript, this should be on your bookshelf (or in your e-reader).

How to Get Eloquent JavaScript

From the publisher, No Starch Press: It’s available in a couple of forms…

  • “Dead-tree” (a.k.a. paper) plus free ebook version: US$29.95
  • Ebook version (includes PDF, mobi, and ePub): US$23.95

From Amazon: Available in these forms…

The old version (free!): The version of Eloquent JavaScript that I’m talking about in this article is the 2011 edition, which is published in paper book and ebook formats. The previous version of the book is available online in the following forms:

This article also appears in the Shopify Technology Blog.

Leave a Comment

{ 1 trackback }

Previous post:

Next post: