Hacker News new | ask | show | jobs
by munificent 2015 days ago
> very easily and completely backwards compatibly.

Object literals, blocks, and ASI take that out of the realm of "very easily":

   var x = if (c) {} else { b: console.log("hi") }
If `c` is true, does this give you `null` from executing an empty block, or an empty object? If `c` is `false`, do you get an object with key "b" and value whatever `log()` returns, or is that a block with a labeled statement?
1 comments

This specific problem was already dealt with during the introduction of arrow functions[1]. It makes sense to keep the same parsing semantics.

[1]: https://www.ecma-international.org/ecma-262/11.0/index.html#...