ECMASCRIPT defines prototype object as prototype property of constructor.
Below is copied from ECMA-262:
4.3.4 constructor function object that creates and initialises objects NOTE The value of a constructor‘s "prototype" property is a prototype object that is used to implement inheritance and shared properties.
Why HTMLDivElement.constructor.prototype == HTMLDivElement ?
if a is a HTMLDivElement object, Object.getPrototypeOf(a) returns HTMLElement while it should return constructor.prototype which is HTMLDivElement.
It's a complete contradict with ECMA standard.
Please help me understanding this concept... Thanks a ton in advance.
HTMLDivElement.constructor.prototype.constructor.prototype == HTMLDivElement.constructor.prototype
in both browser - kirilloid 2012-04-04 18:33
Chrome console shows me:
HTMLDivElement.constructor.prototype == HTMLDivElement
false
The fact it is displayed in console as HTMLDivElement
doesn't mean it is a HTMLDivElement
.
Also: HTMLDivElement.constructor.prototype == HTMLElement.constructor.prototype
HTMLDivElement
is defined as interface by w3c (see http://www.w3.org/TR/html5/the-div-element.html#htmldivelement), so its implementation depends and vary by browser's vendor.
In Chrome is not a proper constructor (just try to execute new HTMLDivElement
), in Firefox it's not a constructor at all (it's an object).