Skip to content

predict · this

Two objects sharing a prototype, and a write to one of them.

Answer before anything runs. Then the machine runs it, and you can step through what it did.

const shared = { role: "viewer" };
const alice = Object.create(shared);
const bob = Object.create(shared);
alice.role = "admin";
const bobRole = bob.role;
const sharedRole = shared.role;
What does `bobRole` hold when the program has finished?
What does `sharedRole` hold when the program has finished?