ternary operator
A JavaScript expression made of a condition, a question mark and two options separated by a colon, giving the first option when the condition is truthy and the second otherwise.
In more detail
It is the only JavaScript operator that takes three operands, hence the name. Conditional types borrow the same syntax at the type level.
Related terms
- conditional type — A type that picks one of two types depending on whether a type is assignable to another, written like a ternary expression with extends.
Taught in
- Conditional Types: Ternary Types And Type Inference With infer — Production TypeScript