Babel supports it if you want to live on the bleeding edge: https://babeljs.io/docs/plugins/transform-do-expressions/
It would be kind of neat if JSX implicitly used "do" expressions in children expressions, though the ternary operator is already very useful in JSX, and more concise [1]
1. https://prettier.io/playground/#N4Igxg9gdgLgprEAuc0DOMAEBhCB...
This is basically what they could translate into without having if/else or nested ternaries.
I'm not sure if it is much better than either but I like it more.
1. Regex style: new match(input, options);
or built in function match(foo, bar);
or like switch match (foo){ cases
}
But, to have the switch statement syntax and return a value seems like a less than good way to implement this.
Aren't decorators also in the works?
Then you HAVE TO HAVE types, otherwise reasoning about effects in these constructed statements would break your mental spine.
Blasphemy.
Not to mention the if/else expression, a ? b : c