Arrow function followed by divide or syntax error?

Andreas Rossberg rossberg at
Wed May 24 07:18:55 UTC 2017

On 24 May 2017 at 08:57, Gareth Heyes <gareth.heyes at> wrote:

>> you'll get a SyntaxError in all browsers but Edge, which interprets it as
>> `(x => {}) * alert(1)`.
>> Given how confusing that expression is, I think that the SyntaxError is
>> the right choice.
>  Well it is a function expression. So IMO Edge is right. It's equivalent
> to:
> x=function(){} * alert(1)

Edge is wrong. Unlike an ordinary function expression, which is a
PrimaryExpression, an arrow function is merely an AssigmentExpression, so
has much lower precedence than any arithmetic operator. The rationale is
that its body doesn't necessarily have braces, so `x => x * 1` would be
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the es-discuss mailing list