Frontend · interactive
Prototypes and the prototype chain
JavaScript objects don't copy methods from classes. Each object links to a prototype, which links to another, up to Object.prototype. Reading a property walks that chain until it finds it, or reaches the end and returns undefined.
class Animal { speak() {} eat() {} }
class Dog extends Animal { bark() {} }
const rex = new Dog(); rex.name = "Rex"; rex.age = 3;rex (own properties)
nameage↓ [[Prototype]]
Dog.prototype
barkconstructor↓ [[Prototype]]
Animal.prototype
speakeat↓ [[Prototype]]
Object.prototype
toStringhasOwnProperty- ↓ null
rex.speak → found on Animal.prototype
Not on rex, so the engine follows the chain: 3 hops to Animal.prototype. Every Dog shares that one function.
Read rex.
1 2 Own properties first, then each prototype in turn, ending at Object.prototype and null.
Writes always go on the object itself.
3 4
In production
Tools and technologies
Classes in JavaScript are built on prototypes.
Not tied to one language — use these names when you search docs or design a system.