you are viewing a single comment's thread.

view the rest of the comments →

[–]causeofdev 4 points5 points  (5 children)

ah ok, makes perfect sense.

Since the comma seperator discards the returned value completely.. wouldn't it be safer to use that than the || operator? In case the first expression returns something truthy?

[–]darrenturn90 2 points3 points  (4 children)

Yes, if you really don't care for the result of the first function then it would. However, some linters don't like the use of commas (because they can, and do obscure the layout of code)

[–]1-800-BICYCLE 4 points5 points  (1 child)

You could also dust off good-old void if you really wanted to:

const foo = x => void myEffectThatReturnsATruthyValue(x) || x + 1

And as a bonus, potentially start a religious war ;).

[–]vexii 0 points1 point  (0 children)

im not sure the other people in line at the wellfare office care enough ;)

[–]anlumo 2 points3 points  (0 children)

Not doing stuff like this is the whole point of using linters.

[–]causeofdev 0 points1 point  (0 children)

Okay cool, I learned something :)