DEV Community

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

Collapse
 
courier10pt profile image
Bob van Hoove • Edited

Nitpick: It's a ternary operator known as the conditional operator. For instance in javascript:

The conditional (ternary) operator is the only JavaScript operator that takes three operands. This operator is frequently used as a shortcut for the if statement.

(ref: MDN Web docs : Conditional (ternary) Operator

I use it quite often. I'm a fan of the formatting style that Nimmo proposes, using a newline for the ? part and another newline for the : such that I don't have to scroll sideways.

Collapse
 
shreyasminocha profile image
Shreyas Minocha

Yeah. Thanks for pointing that out.