Comma operator in Arrow functions

Biju bijumaillist at gmail.com
Sat Mar 14 19:29:56 UTC 2015


I was looking into Firefox implementation of Arrow functions

And noticed this

function a(){return 1,2};
a();

gives "2"


But with same with Arrow functions

a=()=>1,2;
a();


gives "1"


To get answer "2" in Arrow functions you need parentheses, like

a=()=>(1,2);
a();



Is this expected ?



Cheers
GC


More information about the es-discuss mailing list