Initializer expression on for-in syntax subject
brendan at mozilla.org
Fri Mar 14 22:20:22 PDT 2014
Peter van der Zee wrote:
> Which browsers currently don't accept this construct? I wasn't even
> aware that JSC didn't support it at some point.
Did anyone say JSC lacked support? I think KJS followed ES3, and this
was in the ES1 grammar, so I doubt it was never supported.
> Minifiers might rely on this construct. And perhaps some js1k entries,
> if that matters anything.
Extremely doubtful. It doesn't save anything. A minifier cannot count on
the loop iterating 0 times.
> Why is there a desire for banishment anyways? Only lack of consistency
> compared to not using the var keyword,
This is only about the 'var' case. The initialiser in 'for (var x = y in
z)' is due only to reuse of the wrong grammar nonterminal in ES1, based
on JScript de-facto non-standard behavior. It is a wart and a pain to
implement. We don't expect it to be hard to remove, unlike other warts,
but we'll find out.
> or was there a bigger problem with this? The thread comes out of the
> blue to me so I probably missed a prior discussion :)
ES6 revised the old grammar dating from ES1, breaking for(var x = y in
z). That was intentional and discussed in past meetings and threads.
More information about the es-discuss