Looking at the output of UglifyJS2, I noticed that no spaces are required between literals and the
for(var i of[1,2,3])...
Not an expert - I haven't done a JS compiler, but have done others.
ecma-262.pdf is a bit vague, but it's clear that an expression such as
1 in foo should be parsed as 3 input elements, which are all tokens. Each token is a
CommonToken (11.5); in this case, we get
in is an
identifierName. Exactly the same is true when parsing
0b1 in foo (see 11.8.3).
So, what happens when you take out the WS? It's not covered explicitly (as far as I can see), but it's common practice (in other languages) when writing a lexer to scan the longest character sequence that will match something you could potentially be looking for. The introduction to section 11 pretty much says exactly that:
The source text is scanned from left to right, repeatedly taking the longest possible sequence of code points as the next input element.
0b1in foo the lexer goes through
0b1, which matches a numeric literal, and reaches
0b1i, which doesn't match anything. So it passes the longest match (
0b1) to the rest of the parser as a token, and starts again at
i. It finds
n, followed by WS, so passes
in as the second token, and so on.
So, basically, and rather bizarrely, it looks like IE is correct.