JavaScript
The language of the web pages you use every day, also used for servers and command-line tools through Node.js.
Beginner
Values, functions, arrays and objects, and modules in Node.js, with an optional first look at the browser.
Getting started with JavaScript
- JavaScript, ECMAScript and runtimes20 minTell apart the language specification, the engines that run it and the runtimes that add file, network and page access.
- Installing Node.js20 minInstall a current Node.js release, confirm the version from a terminal, and choose between LTS and Current.
- The REPL, scripts and the browser console25 minRun JavaScript three ways, interactively in Node.js, from a saved file, and in a browser console, and see where output goes.
- console.log and friends30 minPrint values, format output with template literals, write without a newline, and read a line of input from the keyboard.
- Syntax, semicolons, comments and strict mode30 minWrite readable JavaScript, understand where automatic semicolon insertion can bite, and know what strict mode changes.
Values, types and coercion
- Primitive types and typeof25 minName the seven primitive types and the object type, and use typeof while knowing where it gives odd answers.
- Numbers and BigInt35 minUse JavaScript's double-precision numbers safely, recognise NaN, Infinity and negative zero, and switch to BigInt for large integers.
- Strings and template literals35 minBuild, slice and search strings, and understand why length can surprise you with emoji and accents.
- Type coercion35 minPredict what JavaScript does when an operator meets the wrong type, and convert values explicitly instead.
- Equality: ===, == and Object.is30 minChoose between strict equality, loose equality and Object.is, and understand why two equal-looking objects are not equal.
- null, undefined, ?? and ?.30 minTell null from undefined, supply defaults without clobbering 0 and empty text, and read nested data that may be missing.
Variables and control flow
- let, const and block scope30 minDeclare variables the modern way with const and let, understand block scope and the temporal dead zone, and know why var is legacy.
- if, switch and the conditional operator35 minBranch in idiomatic JavaScript with if/else, guard clauses, the conditional operator, switch and short-circuit operators.
- Loops: for, while, for...of35 minPick the right loop in JavaScript, including for, while, do...while, for...of, for...in, break, continue and labels.
- throw, try, catch and finally35 minRaise errors with throw, handle them with try/catch/finally, and know the built-in error types, optional catch binding and error causes.
- Debugging JavaScript35 minFind bugs with console output, stack traces, the debugger statement and the Node inspector.
Functions
- Declarations, expressions and arrows35 minWrite functions as declarations, function expressions and arrow functions, and understand hoisting, implicit return and functions as values.
- Parameters: defaults, rest and spread35 minUse default parameters, rest parameters, spread in calls, destructured parameters and options objects.
- Scope and closures35 minUnderstand lexical scope, and use closures to keep state private and to build functions that remember their surroundings.
- Higher-order functions and callbacks40 minPass functions as arguments, return them from other functions, and use map, filter, reduce, partial application, once and debounce.
- Recursion in JavaScript35 minWrite recursive functions, walk nested data, memoise with a Map, and know the stack-size limit of JavaScript engines.
- this (first look)35 minPredict what this refers to in method calls, plain calls and arrow functions, and fix the common ways of losing it with bind.
Arrays, objects and data
- Arrays40 minCreate arrays, read and change them with indexes, push, pop, shift, unshift, splice and slice, search them, and avoid the surprises of length and holes.
- map, filter, reduce and friends45 minTransform arrays without loops using map, filter, reduce, find, findLast, some, every, flat and flatMap, and chain them into pipelines.
- Sorting and non-mutating copies40 minSort arrays correctly with comparators, and use toSorted, toReversed, toSpliced and with to get changed copies without changing the original.
- Objects40 minModel data with object literals, shorthand properties, computed keys, in, Object.hasOwn, delete, keys, values and entries.
- Destructuring, spread and rest45 minUnpack arrays and objects into variables, set defaults and new names, and use spread and rest to copy, combine and collect values.
- References, copies and structuredClone40 minPredict when two names share one object, make shallow and deep copies, and know what Object.freeze does and does not protect.
- Map and Set45 minUse Map for key-value data with any key type, Set for unique values, the Set methods union and intersection, and Object.groupBy to group data.
- JSON45 minParse and produce JSON with JSON.parse and JSON.stringify, use revivers, replacers, indentation and toJSON, and know what JSON cannot represent.
Modules and a first project
- ES modules: import and export45 minSplit code into files with export and import, use named and default exports, re-export, and understand module scope and live bindings.
- package.json and npm basics40 minStart a project with npm init, add a dependency, understand package.json and package-lock.json and semver ranges, and run scripts with npm run and node --run.
- JSON modules, dynamic import and top-level await40 minImport JSON files with import attributes, load modules while the program runs with import(), use top-level await, and find files with import.meta.
- CommonJS in the wild35 minRead older require and module.exports code, see how it differs from ES modules, load one kind from the other, and convert a CommonJS file to ESM.
- Project: a command-line quiz60 minBuild a multiple-choice quiz in four stages from a JSON question file, small ES modules, a validated input loop and error handling, then extend it.
DOM basics (optional browser strand)
- JavaScript in a web page40 minLoad a script into an HTML page with a module script tag, serve the page locally, use the developer tools console, and see how module scope differs from a classic script.
- Selecting and changing elements40 minFind elements with querySelector, change text, attributes and classes, build new elements, and see why textContent is safer than innerHTML.
- Events40 minRespond to clicks and other user actions with addEventListener, read the event object, use bubbling for event delegation, cancel default actions and remove listeners with once and signal.
- Forms40 minRead form input with FormData, check it live with the input and submit events and the constraint validation API, and learn why a server must never trust a browser's checks.
- Project: a todo page55 minBuild a todo page in three stages, with the state in pure functions, saving through localStorage with error handling, and a render function and delegated events for the page.
Intermediate
Classes and prototypes, iteration, asynchronous JavaScript, text and dates, Node.js essentials and testing.
Objects, prototypes and classes
- this, call, apply and bind40 minApply the full set of rules that decide what this is, including new, and use call, apply, bind, thisArg and globalThis on purpose.
- Prototypes and the prototype chain40 minExplain how property lookup follows the prototype chain, and create, inspect and share behaviour through prototypes with Object.create and constructor functions.
- Classes45 minWrite classes with constructors, methods, fields, static members and accessors, and see that they are syntax over constructor functions and prototypes.
- Private members and static blocks35 minHide state and helpers with #private fields and methods, test for them with brand checks, and run set-up code with static blocks.
- Inheritance vs composition45 minBuild classes on other classes with extends and super, subclass Error and Array, add behaviour with mixins, and decide when composing small parts is the better design.
- Property attributes and immutability40 minRead and set the attributes behind every property with property descriptors, and compare preventExtensions, seal and freeze for protecting objects.
- Symbols40 minCreate unique symbol values, use them as property keys, share them through the registry, and hook into the language with well-known symbols such as Symbol.toPrimitive.
Iteration and collections
- Iterables and iterators45 minLearn the iteration protocol behind for...of, spread and destructuring, and make your own objects iterable with Symbol.iterator.
- Generators45 minWrite generator functions with function* and yield to produce sequences lazily, delegate with yield*, and control a generator with next, return and throw.
- Iterator helpers40 minProcess iterators lazily with the built-in map, filter, take, drop, flatMap and reduce methods, wrap iterables with Iterator.from, and join sequences with Iterator.concat.
- Map and Set in depth45 minGo beyond the basics of Map and Set with composite keys, transformations, mutation during iteration, lazy upserts with getOrInsertComputed, and set-like arguments.
- WeakMap, WeakSet and WeakRef35 minAttach data to objects without keeping them alive using WeakMap and WeakSet, and learn why WeakRef and FinalizationRegistry are tools of last resort.
- Stacks, queues, trees and graphs in JavaScript55 minBuild classic data structures idiomatically in JavaScript, with arrays as stacks, a head-indexed queue, linked nodes, binary search trees and graphs walked breadth-first.
Asynchronous JavaScript
- The event loop45 minLearn how one thread runs many tasks, the order of synchronous code, microtasks and timers, and how to schedule and cancel timers.
- Callbacks and their problems45 minRead and write error-first callback code, see why nested callbacks and inverted control cause bugs, and convert callback APIs with util.promisify.
- Promises50 minCreate promises with new Promise, chain them with then, catch and finally, and use Promise.withResolvers and Promise.try.
- async and await50 minWrite asynchronous code that reads top to bottom, handle errors with try and catch, and choose between sequential and parallel awaits.
- Running promises together50 minWait for many promises with Promise.all, allSettled, any and race, handle AggregateError, and limit how many run at once.
- Error handling in async code50 minFind and fix unhandled rejections and floating promises, wrap errors with cause, check thrown values with Error.isError, and retry with backoff.
- Timeouts and cancellation50 minCancel async work with AbortController and AbortSignal, set deadlines with AbortSignal.timeout, combine signals with AbortSignal.any, and pass signals to timers and fetch.
- Async iteration50 minConsume values that arrive over time with for await...of, write async generators, read paginated data lazily, and collect results with Array.fromAsync.
Text, patterns, dates and numbers
- Regular expressions50 minMatch, extract and rewrite text with regular expressions, using flags, test, match, matchAll, replace with functions and split.
- Named groups, lookaround and the v flag50 minWrite patterns you can still read next month, with named groups, lookaround, match indices, the v flag, inline modifiers and RegExp.escape.
- Unicode in JavaScript strings55 minCount and split text correctly, with code points, normalization, well-formed strings, grapheme segmentation and UTF-8 bytes.
- Intl: numbers, dates, lists and plurals60 minFormat numbers, currencies, dates, lists, plurals, relative times and durations for any locale, sort text correctly, and name languages and regions with the built-in Intl objects.
- Date, the legacy API55 minRead and use the built-in Date object safely, covering epoch milliseconds, zero-based months, UTC versus local time, parsing rules and the daylight saving traps.
- Temporal70 min · Node.js 26+Use the modern date-time API, with separate types for dates, times, zoned moments and durations, immutable values and real time zone support.
Node.js essentials
- The Node.js runtime55 minSee what Node.js adds to the language: built-in modules with the node prefix, events and EventEmitter, the process object, environment variables, .env files with --env-file, and the Web APIs that Node shares with browsers.
- Files and paths55 minRead, write and list files with node:fs/promises, build file names safely with node:path, and work with URLs and file URLs, using a temporary directory that cleans up after itself.
- Writing command-line tools55 minBuild a real command-line tool with util.parseArgs, stdin, stdout and stderr, exit codes and a shebang line, and run another program from JavaScript with node:child_process.
- Streams55 minProcess data piece by piece with Node streams: read and write files in chunks, handle backpressure, chain stages with pipeline and Transform, compress data, and meet the web streams that browsers share.
- HTTP: fetch and a small server55 minCall web APIs with the global fetch, read status codes and JSON bodies, send POST requests, and write a small HTTP server with node:http, with every example running against a local server.
- npm, semver and lock files55 minManage dependencies on purpose with semantic versions and ranges, lock files and npm ci, package scripts and node --run, npx, workspaces, and the exports and imports fields of package.json.
Testing and tooling
- Testing with node:test60 minWrite and run unit tests with Node's built-in test runner, using describe and it, node:assert/strict, hooks, async tests, skipping, filtering, watch mode and coverage reports.
- Mocks, spies and fake timers60 minTest code that depends on time, randomness and the network by replacing them with controlled stand-ins: mock.fn spies, mock.method, MockTimers for setTimeout and Date, and snapshot tests.
- Linting and formatting50 min · Node.js 22.13+Catch likely bugs and settle style arguments automatically with ESLint's flat config, Prettier and Biome, plus the zero-install syntax check of node --check.
- Types for JavaScript code55 minGet type checking without leaving JavaScript, with JSDoc comments and the TypeScript compiler as a checker, and learn what Node's type stripping does when it runs TypeScript files directly.
- Project: a tested API client80 min · Node.js 22.13+Build a small REST client as a real package, in stages that each run, with fetch, retries, timeouts and cancellation, then test it with node:test and check it with ESLint and JSDoc types.
Advanced
Metaprogramming, resources and concurrency, binary data, and building and shipping packages.
Metaprogramming and functional patterns
- Proxy and Reflect55 minIntercept the basic operations on an object with a Proxy, forward them correctly with Reflect, respect the invariants, and know when a proxy costs more than it gives.
- Tagged templates45 minWrite tag functions that receive the pieces of a template literal, use raw strings and String.raw, escape interpolated values for HTML, and build small safe languages such as regular expressions and SQL queries.
- Functional patterns50 minWrite pure functions and immutable updates with the non-mutating array methods and spread, compose them with pipe, curry functions for reuse, memoise safely with bounded caches, and know when the functional style costs too much.
- Decorators: status and alternatives45 minUnderstand what the decorators proposal is, why it is not yet JavaScript, how TypeScript and Babel decorators differ, and how to get the same effects today with wrapper functions, accessors and class factories.
- eval, Function and code loading45 minKnow what eval and new Function do, how direct and indirect eval differ, why node:vm is not a sandbox, how to switch code generation off, and which safe alternatives replace dynamic code in everyday programs.
Resources and concurrency
- using and explicit resource management50 min · Node.js 24+Release files, locks and connections at a known moment with using and await using, write your own disposable objects, handle errors raised during cleanup, and manage groups of resources with DisposableStack.
- Advanced async patterns50 minBuild the small concurrency tools that real programs need, with plain promises - a semaphore, a bounded queue with backpressure, retries with exponential backoff, and a token-bucket rate limiter - and test them without depending on timing.
- Worker threads and Web Workers55 minRun CPU-heavy JavaScript in parallel with node:worker_threads - start workers, exchange messages, know what structured clone copies and what transferring moves, build a small worker pool, handle crashes and timeouts - and see the same model in browser Web Workers.
- SharedArrayBuffer and Atomics50 minShare memory between worker threads with SharedArrayBuffer, see a data race lose updates, fix it with Atomics, coordinate threads with Atomics.wait, notify and waitAsync, and know what browsers require before they allow shared memory.
- Streams in depth55 minSee how backpressure travels through a stream pipeline, write transforms as async generators that survive chunk boundaries, implement your own Writable, handle errors and cancellation in pipeline, and use web streams with queuing strategies alongside Node streams.
- Child processes50 minChoose between execFile, spawn, exec and fork, keep user input away from the shell (and know why Node deprecates args with shell true), read exit codes, signals and timeouts, stream data into and out of a child, talk to a forked Node process over IPC, and clean children up with using.
Expert
V8 internals, performance, and security across the supply chain.
Not written yet.