2 ms·
Sigh. As the person who came up with for(of) I can say that's not the reason. for(in) existed in JS, and the semantics were never going to be changed, that was
by olliej 5y ago
Sigh. As the person who came up with for(of) I can say that's not the reason.
for(in) existed in JS, and the semantics were never going to be changed, that wasn't something that was on the table or was ever considered.
However other languages have syntaxes like:
for each (...)
foreach (...)
for ( .. : .. )
All of which would be more consistent and wouldn't require a non-reserved word be reserved in one context.
We couldn't use `foreach` or `for each` as they conflicted with e4x - one directly, the other by being sufficiently similar to not be plausible.
More depressingly for(:) was killed because of the zombie "typed JS" proposal.