DEV Community

Discussion on: What do you think about the ternary operator?

Collapse
 
hudsonburgess7 profile image
Hudson Burgess

I think the ternary operator actually encourages readability.

In my experience, the only time ternary syntax reduces readability is if you have too much logic jammed inside a conditional. And if that's the case, the normal if / else syntax wouldn't make things much clearer.

In other words, the ternary operator just "amplifies" how (un)readable the conditional logic is to begin with. Does that make sense?