What does this log when an array is put on a constructor's prototype?
function Player(name) {
this.name = name;
}
Player.prototype.items = [];
Player.prototype.score = 0;
const a = new Player("A");
const b = new Player("B");
a.items.push("sword");
a.score += 10;
console.log(b.items);
console.log(b.score, a.score);
console.log(Object.hasOwn(a, "items"), Object.hasOwn(a, "score"));
The answer
Work out every line it logs, in order. Then check.
Checking your sign-in…