DEV Community

Discussion on: We don't need a ternary operator

sanderintveld profile image
Sander in 't Veld

But in (condition && b) || c, if condition were true and b were false (or zero), it would return c. So that's not a correct implementation of a ternary operator.

gmartigny profile image
Guillaume Martigny

Indeed, that's part of my point. You can do without ternary with some trickery, but best solution is to split it into real if else over multiple lines.