2011/11/9 John J Barton <[email protected]>

> 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
>   });
>
> This case kind of case is because, as others have noted, incorrect
> |this| binding most often occurs in two cases: 1) mixed OO and
> functional programming (as above) and 2) callback defn.
>
>
In `strict-mode', |this| would resolve to `undefined' inside that function
anyways. I'm not a fan of making constructs "illegal" just because
their semantics might be confusing, even more so when such
disallowance would vary highly in context. It would be bound to
make things more confusing, imho.

Block lambdas are the best solution I can see right now.
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to