← Lessons

quiz vs the machine

Silver1110

Frontend

The Prototype Chain

Objects inherit by linking to other objects, and property lookups walk that link.

4 min read · intro · beat Silver to climb

Lookup by linked objects

Every JavaScript object has a hidden link to another object called its prototype. When you read a property, the engine checks the object itself, then its prototype, then that object prototype, climbing the prototype chain until it finds the property or reaches null.

  • Own properties are found first and shadow inherited ones.
  • Methods usually live on the prototype, shared by all instances.
  • The chain ends at the base object prototype.

How it is wired

Constructor functions set the prototype through their prototype property, and the new keyword links each instance to it. Modern class syntax is sugar over this same mechanism.

  • Object create lets you pick a prototype directly.
  • Assigning a property always writes on the object itself, never up the chain.
  • A long chain costs a few extra lookups but rarely matters.

Inheritance here is delegation, not copying. Instances stay small and shared behavior lives in one place, which is why prototype methods save memory across many objects.

Key idea

Property reads walk up the prototype chain until found, while writes always land on the object itself.

Check yourself

Answer to earn rating on the learn ladder.

1. Where does a property write land by default?

2. What ends the prototype chain?