Why does this work in a Node.js
console (tested in 4.1.1 and 5.3.0) but doesn\'t work in the browser (tested in Chrome)? This code block should create and invok
None of these should work without parentheses.
Why?
Because according in the spec:
So an ArrowFunction cannot be on the LHS of a CallExpression.
What this effectively means in how =>
should be interpreted, is that it works on the same sort of level as assignment operators =
, +=
etc.
Meaning
x => {foo}()
doesn't become (x => {foo})()
x => ({foo}())
(
must have been wrong and throws a SyntaxErrorThere was a bug on Babel about it here, too.