What is Object.__proto__ and how is it different from Object.prototype

74 Views Asked by At

I think this works;

Obj.__proto__ = Object.__proto__

in that it passes same objects to left object. if not, please correct me.

Want to figure out how Obj.prototype

differs from Obj.__proto__

1

There are 1 best solutions below

0
On

Obj.prototype is what you define to be a prototype of every object constructed with:

var obj = new Obj();

Obj.__proto__ is the prototype of the object that is referenced by your Obj variable itself, whatever it is (eg. Obj may be a function if it's a constructor).

Object.prototype is what will be the prototype of every object constructed with new Object().

Object.__proto__ is the prototype of the Object object itself.

But __proto__ is not standard. See Object.getPrototypeOf() for a standard way to get some object's prototype in ECMAScript 5.1 and ECMAScript 6.