How does __proto__ differ from prototype?
In short
| Property | Where it lives | What it stores |
|---|---|---|
__proto__ | On the object | A reference to its prototype |
prototype | On the constructor function or class | The object that becomes the prototype for created objects |
__proto__→ of an already created objectprototype→ on the constructor (template) objects are created from
Example to understand it
function User(name) {
this.name = name;
}
User.prototype.sayHi = function() {
console.log(`Hi, ${this.name}`);
};
const tim = new User('Tim');Now let's see what happens:
console.log(tim.__proto__ === User.prototype); // true
console.log(User.prototype.constructor === User); // trueBreakdown:
User.prototypeis an object that holds methods (sayHi) and serves as the prototype for all objects created vianew User().tim.__proto__is a reference to that veryUser.prototypeobject.
Visually
User (function)
│
├── prototype ──► { sayHi(), constructor: User }
│
└── new User('Tim') → tim {
name: 'Tim',
__proto__: User.prototype
}That is, the __proto__ of a created object points to the prototype of the function that created it.
In plain terms
| Property | What it tells | Example |
|---|---|---|
prototype | "What my children will get" | User.prototype.sayHi = ... |
__proto__ | "Who my parent is" | tim.__proto__ === User.prototype |
Example with a chain
function Animal() {}
Animal.prototype.eats = true;
function Dog() {}
Dog.prototype = Object.create(Animal.prototype);
Dog.prototype.barks = true;
const rex = new Dog();
console.log(rex.barks); // true (on Dog.prototype)
console.log(rex.eats); // true (on Animal.prototype)The chain looks like this:
rex.__proto__ → Dog.prototype → Animal.prototype → Object.prototype → nullEvery object has __proto__,
while prototype exists only on functions and classes
const obj = {};
console.log(obj.__proto__); // Object.prototype
console.log(obj.prototype); // undefined
function Foo() {}
console.log(Foo.prototype); // { constructor: Foo }
console.log(Foo.__proto__); // Function.prototypeOrdinary objects have no prototype, while constructor functions have both: prototype and __proto__.
In modern practice
The __proto__ property is considered legacy. Modern equivalents are recommended:
Object.getPrototypeOf(obj); // instead of obj.__proto__
Object.setPrototypeOf(obj, proto); // instead of obj.__proto__ = protoSummary table
| Property | Where it's used | What it stores | When it applies |
|---|---|---|---|
__proto__ | on the object | a reference to its actual prototype | when you need to know "who is my parent" |
prototype | on the constructor function or class | the object that becomes the prototype for created objects | when creating methods available to all instances |
The key relationship
instance.__proto__ === Constructor.prototypeEvery object created via
new Constructor()gets a reference toConstructor.prototypein its internal__proto__property.
In one phrase:
prototypeis the "blueprint" or "template" that methods for new objects come from.__proto__is the object's "pointer" to that template, the one it inherits everything from.
Short Answer
Interview readyA concise answer to help you respond confidently on this topic during an interview.