Touffy said:
On 2006-10-06 17:03:28 +0200, Michael Winter
<
[email protected]> said:
[snip]
The prototype chain of the global object is implementation-defined.
window is the global object in client-side JavaScript,
The identifier, window, is a property of the global object that refers
to that same object.
but Object is the prototype root object.
Yes, so all built-in prototype objects, with the exception of the Object
prototype object, will include the Object prototype object in their
prototype chains.
Every built-in prototype object has the Object prototype
object, which is the initial value of the expression
Object.prototype (15.3.2.1), as the value of its internal
[[Prototype]] property, except the Object prototype object
itself.
-- Paragraph 8, Section 15 "Native ECMAScript Objects",
ECMA-262 3rd Ed.
That implies that all native objects that have a prototype chain will
therefore also include the Object prototype object in their prototype
chains. However, the global object doesn't necessarily have a prototype
chain: that is left the implementation.
The values of the [[Prototype]] and [[Class]] properties of the
global object are implementation-dependent.
-- Paragraph 3, Section 15.1 "The Global Object",
ECMA-262 3rd Ed.
Every object in JavaScript inherits from Object, including window.
Not true. Only the built-in prototype objects must include the Object
prototype object in their prototype chains. Host objects and the global
object may only if they wish.
There doesn't need to be one at all ([[Prototype]] may be null),
and the global object doesn't need to have a constructor property,
either.
window has a constructor property, as any browser can tell you.
Any browser? MSIE doesn't. Even if it did, that doesn't mean that all
browsers would. As I wrote previously, this an implementation-dependent
matter. If an implementation, such as JavaScript, cares to make the
simplification of using the Object prototype object in every prototype
chain, that's its business, but it's far from a universal necessity.
It is not necessarily Object itself, but window is definitely an
instance of Object.
The global object may be of [[Class]] Object, if an implementation so
wishes, but that is all. Any object that doesn't have a [[Call]]
property is defined this way unless explicitly overridden, so it would
be sensible to follow suit.
[snip]
Mike