ES5 riddle -- this binding in accessors accessed as global vars

Mark S. Miller erights at google.com
Mon May 2 18:04:46 PDT 2011


On Mon, May 2, 2011 at 5:50 PM, Allen Wirfs-Brock <allen at wirfs-brock.com>wrote:

> According to the spec. it should alert the global object:
> The reference to foo resolves to a Reference to an object environment
> record.  When getValue is called on  that reference it goes through step 5.a
> and calls GetBindingValue on the env record.  GetBindingValue does a [[Get]]
> on the global object.  [[Get]] internally retrieves an accessor property and
> does a call to the [[Get]] function passing the global objet as the this
> value.
>

It's not the answer I was hoping for, but on reexamination I see that you're
correct. Thanks.




>
> Allen
>
>
> On May 2, 2011, at 4:43 PM, Mark S. Miller wrote:
>
> > According to the ES5 spec, should the following program alert the global
> object or undefined? Why?
> >
> >     Object.defineProperty(this, 'foo', {get:function(){"use strict";
> return this;}});
> >     alert((function(){"use strict"; return foo;})());
> >
> >
> > --
> >     Cheers,
> >     --MarkM
> > _______________________________________________
> > es5-discuss mailing list
> > es5-discuss at mozilla.org
> > https://mail.mozilla.org/listinfo/es5-discuss
>
>


-- 
    Cheers,
    --MarkM
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20110502/76067aa0/attachment.html>


More information about the es-discuss mailing list