constructor
is a pre-defined [[DontEnum]] property of the object pointed to by the prototype
property of a function object and will initially point to the function object itself.
__proto__
is equivalent to the internal [[Prototype]] property of an object, ie it's actual prototype.
When you create an object via use of the new
operator, it's internal [[Prototype]] property will be set to the object pointed to by the constructor function's prototype
property.
This means that .constructor
will evaluate to .__proto__.constructor
, ie the constructor function used to create the object, and as we have leared, the protoype
property of this function was used to set the object's [[Prototype]].
It follows that .constructor.prototype.constructor
is identical to .constructor
(as long as these properties haven't been overwritten); see here for a more detailed explanation.
If __proto__
is available, you can walk the actual prototype chain of the object. There's no way to do this in plain ECMAScript3 because JavaScript wasn't designed for deep inheritance hierarchies.