DEV Community


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

lorenmcclaflin profile image
Loren McClaflin

With only ~1yr. JS experience, I love the ternary operator.
Sure, it took some practice, especially with those “...or else, or else, or else” statements, but let’s face it, the example BG Adrian uses is diffucult to follow long-hand, as well.
The ternary operator offers us a succinct, efficient alternative to if/then/else blocks.
But- again using BG’s example, I/we can take this as a reminder to reflect on our code, and document - or refactor, to maximize its readability.