DEV Community

Discussion on: The Ternary Operator vs The Conditional Operator WTF

Collapse
 
antogarand profile image
Antony Garand

Tldr:

  • Binary operator = operator with two variables, such as 1 + 2_
  • Ternary operator = operator with three variables, such as true ? 1 : 2

The conditional operator (?:) is a ternary operator, and the addition operator (+) is a binary operator.

As the conditional operator is the only ternary operator, people usually refer to it as the ternary operator, but that isn't completely true.

Collapse
 
joelnet profile image
JavaScript Joel

Correct (mostly).

While The Conditional Operator's name is not The Ternary Operator, it is however correct to reference it by it's type as The Ternary Operator. The difference being one you are calling by name and one by type.

Collapse
 
bluebell_lester profile image
Bluebell Lester

So in the end it doesn't matter what you'd call it until someone comes up with another ternary operator.

Maybe you should call it the ternary conditional operator :D