When returning an object from a function with an arrow, it seems that it is necessary to use an additional set {}and keyword returndue to the ambiguity in the grammar.
This means that I cannot write p => {foo: "bar"}, but I must writep => { return {foo: "bar"}; } p => { return {foo: "bar"}; }
If the arrow returns anything other than the object, then {}, and return, for example, it is not necessary: p => "foo".
p => {foo: "bar"}returns undefined.
The modified p => {"foo": "bar"}produces " SyntaxError: unexpected token: ' :'".
Is there something obvious I'm missing?
source
share