← Back to archive

Stdle #182 · scope · 2026-11-29

What does this JavaScript snippet output?

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

class A {
x = 1;
y = this.x + 1;
constructor() { this.x = 10; }
}
console.log(new A().y);
Scope
4 attempts left

Answer & explanation