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);
}());
```

Best Regards


On Sun, Sep 7, 2014 at 8:28 PM, Garrett Smith <dhtmlkitc...@gmail.com>
wrote:

> On 9/7/14, Andrea Giammarchi <andrea.giammar...@gmail.com> wrote:
> > **implicitly fail** from a user point of view that used "use strict" to
> > avoid receiving the global context in there ... I am not sure how much
> you
> > want to turn it back to me but you are missing the point and I've not
> much
> > else to say.
> >
>
> "use strict" doesn't avoid receiving the global object.
>
> For function calls in strict code, "use strict" says the `this` value
> is supplied by the caller, but if it isn't, the `this` value is
> undefined.
>
> The caller of the callback your example below was setTimeout. Method
> setTimeout maintains a reference to the window and calls callback
> function, `a`, with the window as the thisValue.
>
> setTimeout(
>   function a() {
>     console.log(this);
>   },
> 1);
> --
> Garrett
> @xkit
> ChordCycles.com
> garretts.github.io
>
_______________________________________________
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to