A past puzzle — fully playable. 4 attempts, hints on wrong guesses.
stdle-183.js
1classA{getx(){return"proto";}}
2consta=newA();
3console.log(a.x);
4Object.defineProperty(a,"x",{value:"own"});
5console.log(a.x);
Scope
Answer & explanation
Console output
proto
own
Why
Initially x is an accessor on A.prototype, so the first a.x invokes the getter and returns "proto". Object.defineProperty then installs an own data property x on the instance, which shadows the inherited getter, so the second a.x returns the own value "own". Own properties always take precedence over inherited ones of the same name.