On Sun, Sep 7, 2014 at 10:29 AM, Andrea Giammarchi <
[email protected]> wrote:

> I know this is probably W3C land but the following code shows the global
> object in every JS engine I could test:
>
> ```js
> (function () {
>   'use strict';
>   setTimeout(function () {
>     'use strict';
>     console.log(this);
>     // [window/global Object]
>   }, 0);
> }());
> ```
>

On Sun, Sep 7, 2014 at 11:02 AM, Axel Rauschmayer <[email protected]
<https://mail.google.com/mail/?view=cm&fs=1&tf=1&[email protected]>>
wrote:

> On Sep 7, 2014, at 19:47 , Mark S. Miller <[email protected]
> <https://mail.google.com/mail/?view=cm&fs=1&tf=1&[email protected]>>
> wrote:
>
> On Sun, Sep 7, 2014 at 10:36 AM, Mathias Bynens <[email protected]
> <https://mail.google.com/mail/?view=cm&fs=1&tf=1&[email protected]>>
> wrote:
>
>> On Sun, Sep 7, 2014 at 7:29 PM, Andrea Giammarchi
>> <[email protected]
>> <https://mail.google.com/mail/?view=cm&fs=1&tf=1&[email protected]>>
>> wrote:
>> > This looks like a potential problem when possible passed methods are not
>> > bound + it looks inconsistent with *"use strict"* expectations.
>>
>
> Yes. This looks like a typical screwup. Thanks for pointing it out.
>
>
> Interesting. Follow-up question: isn’t strictness propagated lexically?
>

Yes.



> That is, shouldn’t the parameter of `setTimeout()` be strict even without
> being explicitly declared as such?
>

Yes, it is. That's what demonstrates that this is a W3C land screwup, as
Andrea inferred, rather than a JS issue. The callback is strict. It is
setTimeout itself which is explicitly passing it the global as a
this-binding, rather than passing it undefined. If the callback function
were sloppy, it would see the global object in either case.



-- 
  Cheers,
  --MarkM
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to