The global object in browsers

Brendan Eich brendan at
Tue Feb 17 15:09:13 PST 2009

On Feb 17, 2009, at 2:48 PM, Mark Miller wrote:

> On Tue, Feb 17, 2009 at 2:02 PM, Ian Hickson <ian at> wrote:
> Now, if the other page's script calls f() and g(), it will get  
> different
> results (2 and 1 respectively, if I didn't screw up the example code).
> For HTML5, this behaviour has been defined in more detail. The global
> object is a Window object. This object is per-Document. The object
> returned by the "window" attribute on that global object is actually a
> WindowProxy object, which forwards everything to the "current" Window
> object.
> What do you mean by "current"? Are you proposing to legitimize the  
> dynamic scoping behavior demonstrated by your example?

What Ian showed is not dynamic scoping.

   var global = this;
   function g() { return global.x; }

The issue is what global.x means after the current page (the one  
containing the script including these two lines) has been unloaded and  
a new page loaded (while some other window keeps a reference to g).

> If all major browsers agree on this bizarre behavior, we will indeed  
> be stuck. But if some existing browsers use lexical capture (i.e.,  
> return 1 in both cases), then ES-Harmony should feel free to specify  
> that. What do each of the major browsers do?

What the proxy forwards to, the current inner window or the one  
associated with function g (associated how?) when the expression  
global.x is evaluated, is the *current* inner window for the outer  
(persistent, === identity) proxy denoted by global in the example.

The identity of the inner window, the one at the tail (top is  
confusing, which way is up?) of the scope chain in ECMA-262 terms,  
must not leak or it could be used to subvert access checks done by the  


> -- 
> Text by me above is hereby placed in the public domain
>    Cheers,
>    --MarkM
> _______________________________________________
> Es-discuss mailing list
> Es-discuss at

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the Es-discuss mailing list