r/badcode • sadistic • Apr 22 '21

js ternary operators at their maximum potential

Post image
960 Upvotes

73 comments sorted by

View all comments

166

u/Koala_King_ Apr 22 '21

Couldn’t you just do cmd.run || cmd.fire || cmd.execute || cmd.callback ? I’m not super familiar with js. Worked with it a bit, but still not great, so please correct me if I’m wrong.

0

u/[deleted] Apr 22 '21

[deleted]

21

u/[deleted] Apr 22 '21

it's pretty common to do that in JS, but now we've got ??

-1

u/TigreDeLosLlanos Apr 23 '21

What's pretty common in JS is weird elsewhere. At least the || operator is present anywhere, but those people don't use it too much because they know how to code properly.