"use strict" VS setTimeout

Michał Wadas michalwadas at gmail.com
Sun Sep 7 10:50:26 PDT 2014


`
var temp = window;
document.querySelector('iframe').contentWindow.setTimeout(function() {
console.log(temp === window); // false
})
`
setTimeout is a method of global object, not a standalone function.

2014-09-07 19:47 GMT+02:00 Mark S. Miller <erights at google.com>:
> On Sun, Sep 7, 2014 at 10:36 AM, Mathias Bynens <mathiasb at opera.com> wrote:
>>
>> On Sun, Sep 7, 2014 at 7:29 PM, Andrea Giammarchi
>> <andrea.giammarchi at gmail.com> 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.
>
>
>
>>
>> It’s not just `setTimeout` – other DOM timer methods have the same
>> behavior. The spec is here, FWIW:
>>
>> http://www.whatwg.org/specs/web-apps/current-work/multipage/webappapis.html#dom-windowtimers-settimeout
>> Pretty sure this cannot be changed without breaking the Web.
>
>
> Why? If "undefined" were passed instead, sloppy callback functions would
> still see the same behavior -- on entry they would coerce undefined to their
> global object. Do you think the web already depends on strict functions
> seeing the global object here, rather than undefined?
>
>
>
>>
>> _______________________________________________
>> es-discuss mailing list
>> es-discuss at mozilla.org
>> https://mail.mozilla.org/listinfo/es-discuss
>
>
>
>
> --
>     Cheers,
>     --MarkM
>
>
> _______________________________________________
> es-discuss mailing list
> es-discuss at mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss
>


More information about the es-discuss mailing list