? : (ternary operator)
Single-line if/else.
Syntax
condition ? trueValue : falseValue
Description
Returns the first value if the condition is true, and the second if false. Ideal for short assignments/displays.
Returns
One of two values.
Example
Loading editor…
Expected output
adult
When to use?
Short conditional value assignment, in JSX/templates.