The Roots of Every Object
In JavaScript, every object has a hidden property called [[Prototype]]. It either equals null, or it references another object — that other object is called its prototype.
When you read a property from an object and it doesn't exist there, JavaScript automatically searches for it up the prototype chain.
let animal = { eats: true };
let rabbit = { jumps: true };
Object.setPrototypeOf(rabbit, animal); // set animal as rabbit's prototype
console.log(rabbit.jumps); // true — rabbit's own property
console.log(rabbit.eats); // true — found in animal (the prototype)!
Inheritance is read-only: writing rabbit.eats = false creates a new own property on rabbit and does NOT change animal.
Caution
The old __proto__ property is deprecated. Use Object.getPrototypeOf(obj) to read and Object.setPrototypeOf(obj, proto) to set prototypes.