Putting `global` reference in specs

Andrea Giammarchi andrea.giammarchi at gmail.com
Fri Apr 17 14:55:32 UTC 2015

We have `window` in DOM land, `self` in Workers, and `global` in most
common server side JS engines ... plus we have this in ES6 specification:

> In addition to the properties defined in this specification the *global*
object may have additional host defined properties. This may include a
property whose value is the *global* object itself; for example, in
the HTML document object model the window property of the *global* object
is the *global* object itself.

Now, accordingly with this madness:

8.5 millions checks for `typeof global`

14.1 millions checks for `typeof window`

Does anyone have a concrete reason for NOT specifying **global** as
reference to whatever `window` or `self` reference already?

I've suggested to stick this on top of every wen page:
<script>var global=global||this;</script>

and this on top of every Worker
var global=global||this;

But I'm pretty sure if ECMAScript would have that in specs we might see the
end of the debate and the infamouse `typeof window` or `typeof global`

Thanks in advance for thoughts
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20150417/5a3eb7d4/attachment.html>

More information about the es-discuss mailing list