is [[Prototype]] of global object intentionally unspecified?

# Michael Ficarra (12 years ago)

It has recently come to my attention that, though Object.prototype is in the prototype chain of the global object in all interpreters I've ever used, the [[Prototype]] of the global object is actually unspecified. My question: was this property intentionally unspecified to allow for interpreters to use other objects (or null) as the [[Prototype]] of the global object? If so, it'd be great to add a note to the spec. If not, I'd be glad to open a bugzilla bug to correct the omission. Either way, I think the spec should explicitly mention this value.

# Alan Schmitt (12 years ago)

Here is the related bug report for the test262 test that also assumes this: ecmascript#1600

# Michael Ficarra (12 years ago)

Oh, sorry for the duplicate. It appears you guys were just recently discussing this, though it failed to turn up in my searches. For what it's worth, I would prefer for it to be specified that the global object's prototype chain must include Object.prototype. I am sure there's plenty of code that depends on that.

# Brendan Eich (12 years ago)

Michael Ficarra wrote:

specified that the global object's prototype chain must include Object.prototype. I am sure there's plenty of code that depends on that.

Yes, that's required.

# David Bruant (12 years ago)

Le 05/08/2013 17:08, Brendan Eich a écrit :

Michael Ficarra wrote:

specified that the global object's prototype chain must include Object.prototype. I am sure there's plenty of code that depends on that.

Concern shared.

Yes, that's required.

Would it make sense to leave ECMAScript spec intact (global's [[Prototype]] is implementation-dependent), but have WebIDL put requirements on the prototype chain? That would allow non-web contexts to have null as [[Prototype]]; and some people seem to want to do that 1.

I imagine that code that requires the global object to inherit from Object.prototype is code doing window.hasOwnProperty('whatever') which is only needed for web compat and isn't really given modern JavaScript practices.

# Brendan Eich (12 years ago)

David Bruant wrote:

Would it make sense to leave ECMAScript spec intact (global's [[Prototype]] is implementation-dependent),

No, we want interop across, e.g., Node.js and browsers, on such "features" as whether toString resolves as a global reference.

# David Bruant (12 years ago)

Le 05/08/2013 20:11, Brendan Eich a écrit :

David Bruant wrote:

Would it make sense to leave ECMAScript spec intact (global's [[Prototype]] is implementation-dependent),

No, we want interop across, e.g., Node.js and browsers, on such "features" as whether toString resolves as a global reference.

Filed ecmascript#1714

# Alan Schmitt (12 years ago)

es-discuss at michael.ficarra.me writes:

Oh, sorry for the duplicate. It appears you guys were just recently discussing this, though it failed to turn up in my searches.

The discussion only started on test262. If it's going to entice a spec change, it's great to talk about it here. Thanks a lot!

# Alan Schmitt (12 years ago)

bruant.d at gmail.com writes:

Would it make sense to leave ECMAScript spec intact (global's [[Prototype]] is implementation-dependent), but have WebIDL put requirements on the prototype chain? That would allow non-web contexts to have null as [[Prototype]]; and some people seem to want to do that [1].

We don't advocate for any specific case, and we could easily change our implementation to use something other than null for the prototype of the global object. This case came up while looking at the tests we fail, and we simply wanted to clear it up.