Part 1 — Mental Model
What JS is in one screen, ECMAScript vs JavaScript, engines & runtimes, JIT — the fast-path rules
A one-screen mental model of what JavaScript is. The rest of the handbook is the detail.
What JavaScript is#
High-level, dynamically-typed, multi-paradigm (imperative, functional, prototypal-OO), single-threaded, garbage-collected, conforming to the ECMAScript spec. Functions are first-class values; inheritance is prototypal (classes are sugar).
| Property | Consequence for you |
|---|---|
| Dynamically typed | Type errors surface at runtime → why TypeScript exists |
| Single-threaded | No data races on JS values, but never block the thread |
| Interpreted + JIT | Fast after warm-up; consistent shapes/types stay on the fast path (Part 20) |
| Garbage collected | No manual free, but leaks happen via lingering references |
| Prototype-based | class is sugar; prototypes are the real model (Part 10) |
ECMAScript vs JavaScript#
ECMAScript is the spec (maintained by TC39). JavaScript is an implementation plus host APIs that are not part of ECMAScript. Array.prototype.map is ECMAScript; document.querySelector (browser) and fs (Node) are host APIs.
Engine, runtime, environment#
- Engine — parses and executes JS: V8 (Chrome, Node, Edge, Deno), SpiderMonkey (Firefox), JavaScriptCore (Safari, Bun).
- Runtime — the engine plus host APIs (DOM /
fetch/ timers, or Nodefs) plus the event loop. Browser and Node are different runtimes over (often) the same engine. - V8 pipeline — Ignition (bytecode interpreter) → Maglev/TurboFan (optimizing compilers). Hot code is speculatively optimized and deoptimized when its assumptions break.
JIT — the fast-path rules 🎯#
JS starts interpreting immediately (fast startup) and compiles hot code to machine code on the fly. To stay optimized: keep object shapes stable (initialize all fields in the constructor, same order; don't delete) and keep a function's argument types consistent. Details and the "why" in Part 20 (hidden classes, inline caches).
The event loop, promises, and micro/macrotask ordering are covered in depth in Part 16.