Learn JavaScript: an interactive guide to the language
Understand what your code does
JavaScript is easy to start and surprisingly easy to misread. A copied object still changes. A function remembers a variable. A promise runs before a timer. The interesting part is understanding why.
A chapter-by-chapter JavaScript reference, from primitive values and operators to promises and modules. Read the notes, follow the code examples, and explore the interactive experiments.
Try one
Four lines of code, one surprising order. Step through them and watch where each callback waits before it runs.
console.log('A');setTimeout(() => console.log('timer'), 0);Promise.resolve().then(() => console.log('promise'));console.log('B');
Step 0 of 6: Guess the order the four logs will print, then press Next step.
Chapters
CHAPTER 1
Fundamentals
Values, operators, conversions and control flow: the pieces every program is built from.
CHAPTER 7
Modern JavaScript and practice
Modules, tooling, and the habits that make you a better developer.
Glossary
- Closure
- A function together with access to the variables of the scope it was created in.
- Prototype
- An object consulted when a property is missing on another object.
- Hoisting
- Declarations are set up before code runs, so some can be used above the line that declares them.
- Coercion
- JavaScript converting a value to another type implicitly, as in "5" * 2.
- Callback
- A function passed to another function, to be called later.
- Promise
- An object standing in for a value that will be available later, or an error.
- Microtask
- Work, such as a promise reaction, processed after the current stack empties and before the next task.
- Scope
- The region of code where a variable can be accessed.
- Primitive
- An immutable value that is not an object: string, number, bigint, boolean, undefined, symbol or null.
- Event Loop
- The mechanism that takes queued tasks and runs them once the call stack is empty.
- Destructuring
- Unpacking values from arrays or properties from objects into separate variables.
No matching term.