The second line in this statement causes an error. I understand if I wrap the lambda in parentheses it solves the problem as in the first line. I'm just curious why it is an error, as in JavaScript a lambda there would work fine.
var okay = true && (() => {});
var fails = true && () => {};
It is a precedence issue:
var fails = true && () => {};
// <-- Error: Expression expected
... is equivalent to:
var fails = (true && ()) => {};
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With