In my code, I have something that boils down to the following:
var x = y || ()=>{};
(In case you are interested, I call x() later, and y may be defined as a function or it may not be, so I donβt want a TypeError to be thrown if it is not.)
For some reason this causes
SyntaxError: Unexpected token)
Why? I learned that
var x = y || (()=>{});
works fine but
y || ()=>{}
does not work. Is this indicated, or a bug in V8 or Chrome? (I tested this only in the latest version of Chrome stable.)
javascript arrow-functions
user7586097
source share