Skip to content
JavaScript·Intermediate·Coding·1 min read

How does property lookup use the prototype chain?

Short interview answer

The engine first checks the object's own properties. If absent, it follows the object's internal [[Prototype]] link and repeats until it finds a property or reaches null. Accessor properties may execute a getter with the original receiver as this.

Example

JavaScript
const animal = { speak() { return 'generic'; } };const dog = Object.create(animal);dog.bark = () => 'woof';
dog.bark();  // 'woof'    — own propertydog.speak(); // 'generic' — found one level up on `animal`dog.fly;     // undefined — chain ends at Object.prototype -> null

Key takeaway

Explain the underlying mental model clearly, then support it with a concrete example and its trade-offs.

← Back to Prototype chain

Related questions