Comma operator in Arrow functions

Biju bijumaillist at gmail.com
Sat Mar 14 20:25:59 UTC 2015


> So: `var a = (x) => 1, 2;` -> syntax error (not a VariableDeclaration)
>
> Is all I was saying.
>

>> hence:
>>
>> a=1,2
>>
>> parses as:
>>
>> (a=1),2
>>
>> and
>>
>> a=()=>1,2
>>
>> parses as:
>>
>> (a=()=>1),2
>>
>> Finally, note that
>>
>> console.log(a=1,2)
>>
>> assigns the value 1 to a, but outputs 2
>>
>> Allen

Looks like I can agree with above, b
But why in case of

x=1,2;

assigns 2 to x?


More information about the es-discuss mailing list