Master JavaScript
The language, not the browser. Values and coercion, closures, prototypes, the one thread that drains two queues, and the rules behind every piece of JavaScript that looks strange until somebody states them plainly.
Contents
Master JavaScript
What JavaScript is, and how to run it
JavaScript's reputation for weirdness starts with a confusion about what it even is: a specification, an engine that implements it, and a host program that lends it everything else. This section separates those three, gets you running and inspecting code on this page and on your own machine, and teaches you to read a failure all the way down. Then it lays down the ground rules the rest of the course builds on: how a program is shaped, where semicolons appear without being written, the eight types, the two kinds of absence, and how a name comes to exist. It closes with the smallest set of tools that lets you write a program of your own.
- 9 min
The specification, the engine and the host
Three separate things have to line up before a line of JavaScript does anything, and only one of them is the language.
- 8 min
Running a line, and seeing a value
A REPL, a file and the box on this page, plus the one function you will use to look inside everything.
- 12 min
Getting it onto your own machine
A terminal, Node.js and a text editor, then one file that runs, and the four things that go wrong on the way there.
- 11 min
Reading an error all the way down
The name, the message and the stack: what each part of a failure tells you, and which line of your own file to open.
- 9 min
The shape of a program
Expressions produce values, statements do things, and knowing which is allowed where explains most early syntax errors.
- 10 min
Semicolons you did not write
JavaScript finishes some statements for you, and the two line shapes where it guesses wrong break your program quietly.
- 10 min
Comments, names, and the three dialects
How to write a note, what a name is allowed to contain, and why the same file means different things depending on how it is loaded.
- 10 min
Eight types, and where typeof lies
Seven kinds of single value, one kind that lives by reference, and the three answers `typeof` gives that are not what they look like.
- 8 min
Two kinds of nothing
`undefined` means nobody supplied a value; `null` means somebody supplied its absence. Mixing them is a design decision you make once.
- 10 min
Names: let, const and the block they live in
Two ways to declare a name, the braces that bound it, and why a `const` object can still change under you.
- 10 min
Before a name exists
Three different failures that all look like a missing variable, how to tell them apart from the message, and how to reach the global scope on purpose.
- 9 min
Checking a claim without asking anyone
Where the two authoritative documents are, how to read an edition number, and how to ask the runtime in front of you instead of guessing.
- 16 min
Enough to write a small program
A function of your own, a decision, a loop, a list to collect an answer in, and the handful of text operations the problem sets need.
- Easy
One line, the way console.log writes it
Coding problem · Printing, Strings, Fenceposts
- Easy
What typeof would say
Coding problem · Types, typeof, Strings
- Medium
A settings file with two kinds of missing
Coding problem · null and undefined, Strings, Absence
- Medium
A linter for lines that will be swallowed
Coding problem · Semicolons, ASI, Tooling
- Medium
Taking the comments out
Coding problem · Comments, Strings, Tooling
Section quiz
Numbers, strings and text
Opens once you finish What JavaScript is, and how to run it, including its quiz.
Coercion and equality
Opens once you finish Numbers, strings and text, including its quiz.
Operators and control flow
Opens once you finish Coercion and equality, including its quiz.
Functions, scope and closures
Opens once you finish Operators and control flow, including its quiz.
Objects, references and `this`
Opens once you finish Functions, scope and closures, including its quiz.
Prototypes, classes and metaprogramming
Opens once you finish Objects, references and `this`, including its quiz.
Arrays, collections and iteration
Opens once you finish Prototypes, classes and metaprogramming, including its quiz.
Errors, failure and debugging
Opens once you finish Arrays, collections and iteration, including its quiz.
One thread: the event loop, memory and speed
Opens once you finish Errors, failure and debugging, including its quiz.
Promises and async/await
Opens once you finish One thread: the event loop, memory and speed, including its quiz.
Patterns, data formats, time and bytes
Opens once you finish Promises and async/await, including its quiz.
Modules, packages and the JavaScript you inherit
Opens once you finish Patterns, data formats, time and bytes, including its quiz.
Master JavaScript unit exam
Opens once every section is finished and every quiz is passed.