How to Learn JavaScript

TL;DR: If you read and understand Eloquent JavaScript you will be an employable coder.

JavaScript is the programming language read by web browsers.

Reasons to learn

A few reasons it's a good choice for your first or next programming language:

  • Usefulness: Almost every website and web app uses JavaScript. And since every device has a web browser installed on it, so with JavaScript, you can make a program that will run on any device. You can also make "native" mobile apps with it using something like Cordova or React Native. It can also run on servers using NodeJS
  • Non-trendiness: JavaScript is fairly old. This is good because it means it is not just a trend that will be irrelevant in a few years. Lindy Effect approved!
  • Trajectory: Becoming more and more popular, used for more and more things.
  • Economy: It's your only option if you want to make web apps with a single programming language. If you choose Python, Ruby or PHP, you will end up also wanting to learn JavaScript.

Prerequisites (optional)

I suggest learning HTML first, and perhaps CSS as well.

HTML, CSS and JavaScript are the three languages that web browsers read. HTML is for structuring your content in a way the browser understands. CSS is for telling the browser how the content should look (layout, fonts, etc.). JS is for interactivity – when you want your web page *do* something, rather than just sit there like a... page!

With only HTML and CSS you can make a static pages that just sit there in the web browser doing nothing. JavaScript is for making programs. Programs *do* things, oftentimes modifying the HTML and CSS.

I don't recommend that you worry about mastering or memorizing HTML and CSS before moving on to JavaScript. You just need to get the basic idea for now. In a few hours, you will know what you need to know and you can get going with JavaScript.

How to learn

Read the book Eloquent JavaScript.

If you read and understand this one book, you will have a very respectable foundation for programming, especially programming for the web. It's not that long.

Out of all possible learning materials, I chose this one because:

  • It is a good way to learn not only JavaScript as a language, but also general computer programming concepts that are relevant to all languages. This is especially important if you have never built complicated programs before.
  • It's written in a playful way that show the author's love for the topic. Not boring or dry.
  • It includes little tutorial projects. It's important to balance theory with *doing*.
  • It's available for free online. I enjoy my paper copy, and buying one is a way of signalling your commitment to yourself and others, but if you want you can just read it for free online.
  • The online version actually gives you little windows that you can type and run code in, which you may want to use even if you have a paper copy.
  • Books in general have an important advantage over interactive tutorials such as Codecademy and freeCodeCamp. They allow you to skip through stuff you think might be irrelevant or that you already understand. That said, I do not discourage you from using those two. I have personally gone through Codecademy as well and found it useful, but also very slow since I had already read Eloquent JavaScript. A strength of using these interactive tutorials is that you are forced to actually write code yourself whereas with a book you can give yourself excuses not do to the exercises.
  • I have personally read this book. I read it after hacking away for years, having no idea what I was doing. I wish I would have read this book earlier.

After this

You can use freeCodeCamp and Codecademy to reinforce what you've learned or just jump into making your own website or app.

If you know JavaScript well and have done a couple projects, you are employable as a computer programmer.

Hat tip to Derek Sivers who inspired much of this recipe. His suggestions are slightly different and he has more ideas on how to make the new knowledge stick.