re: We don't need a ternary operator VIEW POST

re: IMO (in JS at least), binary operator use for non-binary are good if you know what you're dealing with. const a = b || default; // Fallback to d...

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.


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.

code of conduct - report abuse