On Sun, Sep 7, 2014 at 12:50 PM, Garrett Smith <[email protected]> wrote:
> On 9/7/14, Andrea Giammarchi <[email protected]> wrote: > > this is getting nowhere ... yeah Garret, you can use `.call` and we all > > know that ... > > > > Now I want you to answer this: why on earth would you expect a global > > context in a setTimeout or setInterval operation for a function/method > you > > have explicitly defined as strict ? > > > > One single use case ... do you have it ? > > > > 'cause you don't use "use strict" inside method/functions passed to > > `addEventListener` as example, do you? > > > > So I will close the loop with the very initial snippet and just one extra > > comment > > > > ```js > > (function () { > > 'use strict'; // <== as a developer, I don't want implicit window > > setTimeout(function () { > > 'use strict'; // <== as a developer, I don't want implicit window > > console.log(this); > > // [window/global Object] > > // SO WHY ON EARTH I HAVE AN IMPLICIT window HERE ? > > }, 0); > > }()); > > ``` > > > > setTimeout is explicitly calling your callback with the window. It's > specified to do so in HTML5. It is a little strange. Should HTML5 be > changed? > Yes, this is indeed the only question that Andrea and I are raising in this thread. As you acknowledge, providing window here is a little strange. I quibble with "a little". When a surprise surprises by providing less authority than expected, I don't much care. When the surprise is that more authority is provided than expected, that's a more serious issue. > > > http://www.whatwg.org/specs/web-apps/current-work/multipage/webappapis.html#dom-windowtimers-settimeout > -- > Garrett > @xkit > ChordCycles.com > garretts.github.io > -- Cheers, --MarkM
_______________________________________________ es-discuss mailing list [email protected] https://mail.mozilla.org/listinfo/es-discuss

