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.

ES6 / 2015

ES20152015

The largest single revision of the language. Block scoping, lexical `this`, class syntax, and a standardised Promise — the foundation of every later feature.

Arrows have no own `this`, `arguments`, or `prototype`. They close over the enclosing binding, which removed a whole genre of `var self = this` workarounds.

// In sloppy mode a plain function call rebinds `this` to the global
// object. The arrow closes over the enclosing `this` instead — the object.
const counter = {
  count: 0,
  startLexical() {
    [1, 2].forEach(() => { this.count++; }); // arrow keeps this = counter
    return this.count;
  },
  startClassic() {
    [1, 2].forEach(function () { this.count++; }); // classic loses it
    return this.count;
  },
};

console.log("arrow keeps this → counter.count =", counter.startLexical());
console.log("classic loses it → counter.count still", counter.startClassic());
console.log("classic incremented a phantom global:", globalThis.count);

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