JavaScript:ConditionalOperator
lastmod 2026-11-10created 2022-09-263 edits
The JavaScript conditional operator is the only ternary operator, written in the form condition ? value if true : value if false. Because it returns one of two values depending on the result of the condition, it is used to reduce a simple if-else statement to a single expression. Nesting it hurts readability, so it is usually used only for short branches.
Conditional operator or Ternary operator.