lexical for-in/for-of loose end

Allen Wirfs-Brock allen at wirfs-brock.com
Tue Jan 31 08:28:23 PST 2012

On Jan 30, 2012, at 6:38 PM, Brendan Eich wrote:

> No! We have a standing agreement to get rid of the awful, lazy-grammar-reuse error in ES1 that allows an initializer in for(var x=i in o). We do not want this at all for 'let' in either for-in or for-of.

Fine by me, WRT let/const

We haven't done a very good job of capturing such agreements.  I don't think this one is reflected on the wiki proposals...
> I think we should break unconditionally and forbid =i in for(var x=i in o) too, but that is a separate issue. This botch in grammar factoring is a (bad) sunk cost that has zero bearing on the fresh let binding per iteration idea. It's terrible anti-precedent. Just say no.

While I think the language would be better without it.  I don't really see how we can justify such a breaking change.  Heck, I can even think of a plausible use:

function hasEnumerableProperties (obj) {
   for (var key = false in obj);
   return key!==false


More information about the es-discuss mailing list