making |this| an error (was Re: for own(...) loop)

Andreas Rossberg rossberg at
Wed Nov 9 07:28:20 PST 2011

On 9 November 2011 16:10, John J Barton <johnjbarton at> wrote:
> I'm sure this has been discussed before, but isn't is possible and
> desirable to make |this| illegal in "using strict;" when it can be
> determined from the AST alone that |this| will bind to |window|?  eg:
>   Object.keys(foo).forEach(function(key) {
>     // this is undefined-> window
>   });

How do you know statically that `this' would be undefined? Somebody
might have modified forEach.

In JavaScript, you generally don't know a whole lot of things statically.


More information about the es-discuss mailing list