Look at this screenshot:
I first made a mistake. I know that arrow function can return a value without using the "return" keyword, like f=()=>3
. I thought that I can use this compact syntax to return an object, like f=()=>{a:3}
. After trying it, I realised that "{a:3}" in this case is interpreted as the function body, not object literal. Further trying f=()=>{a:3; return 'three'}
confirmed this: JS interpreted what inside {} as function body, and "a:3" not a property but a statement.
My question is then:
What statement is a:3;
? What's this syntax? What does it do? I cannot find any reference about it. Very strange...