All posts
postApril 1, 2026

Prototype Chain Explained

#javascript#prototype#inheritance#interview
How does the JavaScript prototype chain work? How does property lookup traverse it?

Every object in JS has an internal [[Prototype]] link (accessible via Object.getPrototypeOf or __proto__). When you access a property, the engine: 1. Checks the object itself 2. If not found, follows [[Prototype]] to the parent 3. Continues up the chain until Object.prototype 4. Returns undefined if still not found ```js const animal = { breathes: true }; const dog = Object.create(animal); dog.barks = true; dog.barks; // true (own property) dog.breathes; // true (inherited from animal) dog.flies; // undefined (not in chain) Object.getPrototypeOf(dog) === animal; // true ``` class syntax is syntactic sugar over this prototype mechanism.