Re-Learning JavaScript

Until a few years ago I didn’t really think of JavaScript as a programming language. At first it was just something that could be used to create flashy animations, counters and so on, and it usually just involved copy/pasting code that someone else had written and perhaps modifying a few lines to meet the requirements of the task at hand. Later on it became a gap filler for things that could not be done with PHP and CSS alone – usually DOM manipulations or making Ajax calls – but with jQuery to hide most of the complexity and an abundance of code examples available on Stack Exchange and elsewhere, there still wasn’t any real need to properly learn JavaScript.

And then at some point I found myself writing complete web apps in JavaScript with frameworks like Angular, Ember, and Meteor, and the on-the-job learning approach didn’t work so well anymore. The job got done, but with the increased complexity I felt more and more uncomfortable with my incomplete understanding of the code I was writing. I realised that, unless I took a more systematic approach to learning JavaScript, sooner or later I was going to overlook something that would come back later and bite me really hard.

However, properly learning a programming language that I had already been using for several years didn’t turn out to be as easy as I had expected. While there are many, many books and articles written about JavaScript, they tend to target either absolute beginners or cover specialised topics. If you already know several other languages, a book that uses the first 100 pages explaining things like boolean logic, conditionals, loop constructs, etc. in great detail isn’t going to be helpful, and in-depth articles about more advanced topics such as promises or prototypes tend to assume that you already completely understand the basics they are building on.

Looking back at the various books, articles, and other resources I have been using to better learn JavaScript, there are a couple that I have found particularly helpful. If I had to repeat that learning process all over again, these are the resources I would reach for first:

Eloquent JavaScript by Marijn Haverbeke. After trying to avoid it for a while, I finally decided that I really did need to go through a complete, structured presentation of the language. Haverbeke’s book is well written, and although it didn’t feel as if I was learning much on a chapter-by-chapter basis, I did end up with a better overall understanding of the language.

Eloquent JavaScript is available both online and in print and eBook formats. It only covers JavaScript as described in the ES5 specification, but for the purpose of understanding the overall structure of JavaScript that isn’t really a problem. There a plenty of code examples, and a couple of chapters are dedicated to more extensive learning projects.

You Don’t Know JavaScript is a series of six short JavaScript books by Kyle Simpson (with contributions from many others). Each volume in the series is a deep dive into some aspect of the language – for example, an entire volume is dedicated to the thismechanism and a comparison of objects in JavaScript with classes and objects in other languages.

The You Don’t Know JavaScript volumes are more work to get through than Eloquent JavaScript, but they are also much more likely to be something that you will refer back to later on. ES6 and later JavaScript versions are covered in the last volume, and relevant ES6+ features are covered in appendices to the first five volumes.

Taking the time out of a busy schedule to learn the basics of something that you have already been using for a while may not seem attractive. However, JavaScript has some unique features that makes it hard to learn as you go along, especially if you are used to languages like Java or C++. I’d like to think that the resources above have helped me become a better JavaScript programmer – or at least a less frustrated one!