JS

runtime.js

One spine: the evolution of JavaScript

Pick an era, expand a concept, and see where it lands in today's runtimes. Every snippet can be dropped straight into the sandboxed console — the event loop panel then shows real, instrumented execution, not a looping animation.

Modern JS

ES2020+2020 – today

Yearly, incremental releases. Small operators that erase enormous amounts of defensive boilerplate, plus top-level await for module-scope asynchrony.

`toSorted`, `toReversed`, `toSpliced`, `with`, and `.at` return new arrays instead of mutating in place. Combined with negative indexing, immutable updates become readable and free of the classic copy-then-mutate footgun.

const scores = [80, 30, 55];

const sorted = scores.toSorted((a, b) => a - b);
const reversed = scores.toReversed();
const replaced = scores.with(1, 99);
const cut = scores.toSpliced(0, 2);

console.log("original untouched:", scores);
console.log("toSorted:", sorted);
console.log("toReversed:", reversed);
console.log("with(1, 99):", replaced);
console.log("toSpliced(0, 2):", cut);
console.log("scores.at(-1):", scores.at(-1));

// The old way copied first, then mutated:
const legacy = [...scores].sort((a, b) => a - b);
console.log("legacy copy+sort:", legacy);
When each runtime shipped them
V8`.at()` in V8 9.2 (2021); the `toSorted`/`toReversed`/`toSpliced`/`with` copy methods in V8 11.4 (2023).
Node.js`.at()` since Node 16.6; the four copy methods since Node 20.
Deno`.at()` in Deno 1.16; the copy methods in Deno 1.34.
BunThe full set has been available since Bun 1.0 via JavaScriptCore.

Interview gotchas

15 genuinely tricky, well-known snippets — event-loop ordering, closures in loops, and `this`-binding traps. Open one, read the gotcha, then drop it straight into the sandboxed console to watch it really run.

Event loop
Closures & scope
this binding
Promises & async
Coercion & equality
Built-in traps