← Back to archive

Stdle #158 · scope · 2026-11-05

What does this JavaScript snippet output?

A past puzzle — fully playable. 4 attempts, hints on wrong guesses.

class Counter {
n = 0;
inc = () => ++this.n;
}
const c = new Counter();
const f = c.inc;
console.log(f(), f());
Scope
4 attempts left

Answer & explanation