News for hackers. Stuff that matters.
Re:ECMAScript for XML - Direct XML Syntax in ECMAScript by WorldMaker on Wednesday June 02, 2021 @08:21PM (#27375667)
Huh? The current behavior of for(in) dates all the way back to the original JS standards (ES1). ES2015 had to use "of" to avoid breaking compatibility with existing ES1 for(in) usage. (Being able to replace/reuse for(in) would have kept JS more in line with Python which is also for/in.) It seems fairly sensible in comparison to some of the other proposed options.

Unless you were hoping for an entirely new keyword such as foreach (like C#'s foreach(in)), and in that case yes they couldn't do that because ES3 settled on a Reserved Keyword list and they didn't want to break ES3 compatibility either. While ES3 attempted forward compatibility by including some keywords related to E4X (and ES4's type system), the list of keywords they came up with in ES3 wasn't "because" of E4X. (It was because of "strict mode" and defining what "strict" meant as rather, er, strictly as possible.)

Re:ECMAScript for XML - Direct XML Syntax in ECMAScript by olliej on Wednesday June 02, 2021 @09:25PM (#27376126)
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.