Four generations of the Ashgrove line linger within these walls, each ancestor bound to the room they once kept. Nothing here is truly yours until you prove it — knock on your own doors first, and if they answer not, climb toward the dead who came before you. Every room you search is real JavaScript, running as you play.
Every object in JavaScript is a room. This mansion turns that idea into somewhere you can actually walk through.
__proto__, the next
room in the chain.Read the question in the top bar. If the matching furniture is visible in your current room, click
it. If instead you only see an empty pedestal with that name, climb the stairs and check the next room —
repeat until you find it, or until the attic (Object.prototype) proves it was never there
at all.
Every action you take is mirrored as real code — press 🖥 View the Code any time to see the exact JavaScript your choices are equivalent to.
When you ask for a property that isn't sitting on the floor of the room you're in, JavaScript doesn't
give up — it climbs upstairs to the room's prototype, and if that room doesn't have it either,
it keeps climbing, generation after generation, until it reaches the attic: Object.prototype.
If even the attic is empty, the search ends and you get undefined. This upward search is
called walking the prototype chain, and it happens every time you read a property — you
just never see the stairs.
const grandfather = { landDeed: "Mansion Deed" };
const father = Object.create(grandfather);
const you = Object.create(father);
you.landDeed;
// → "Mansion Deed" (found three floors up)
obj.__proto__ (properly: Object.getPrototypeOf(obj)) is the door at the top
of a room's staircase — it points to the very next room up. It is not a copy of the parent's furniture;
it is a live link. If the ancestor's room changes, everyone downstream feels it immediately, because they
were never holding a copy — only a door.
Reading climbs the chain. Writing never does — you.name = "New" always places furniture
in your own room, even if an ancestor already owns a "name". That is exactly how shadowing is
born.
Shadowing happens when a descendant room has its own version of an item an ancestor also owns. JavaScript always stops at the first match walking up from where you started — so the descendant's version answers, and the ancestor's identical item goes dark, unreachable through that name, for as long as you're standing downstream.
The ancestor's item isn't destroyed — it's still upstairs. It is simply shadowed: hidden behind a closer answer.
const father = { surname: "Ashgrove-Senior" };
const you = Object.create(father);
you.surname = "Ashgrove";
you.surname;
// → "Ashgrove" (Father's version never answers)
Object.create(parent) builds a brand-new, empty room and hangs a single door at the top
of its staircase pointing at parent. The new room owns nothing yet — every item you see in
it at first is a translucent ghost, borrowed from upstairs. The moment you place your own furniture, it
becomes solid, and if it shares a name with something upstairs, it starts shadowing it.
const founder = { motto: "Memento Mori" };
const medium = Object.create(founder);
medium.motto;
// → "Memento Mori" (ghosted, inherited)
medium.hasOwnProperty("motto");
// → false — it isn't really hers, yet
obj.hasOwnProperty(key) is the one question that never climbs the stairs. It only checks
the floor you're standing on — "is this furniture truly mine, in this very room?" — no matter what might
be found further up. It's the difference between "can I access this?" (which walks the chain) and "do I
own this?" (which never does).
you.hasOwnProperty("surname");
// → true — it's your own
you.hasOwnProperty("landDeed");
// → false — that belongs to Grandfather
for...in loops walk the entire chain, picking up inherited furniture as if it were
your own, unless guarded with hasOwnProperty.Object.prototype, whose own __proto__ is
null — the one door in the mansion that opens onto nothing at all.You have walked the prototype chain from the nursery to the founder's attic, four generations tall, and every door has finally answered true.