← Back to archive

Stdle #148 · scope · 2026-10-26

What does this JavaScript snippet output?

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

function F() {}
Object.defineProperty(F.prototype, "x", { value: 1, writable: false });
const f = new F();
try { f.x = 2; } catch (e) {}
console.log(f.x, f.hasOwnProperty("x"));
Scope
4 attempts left

Answer & explanation