# Ternary Operator

*noun*

say it: **“TER-nuh-ree OP-er-ay-ter”** **/ˈtɜːrnəri ˈɒpəreɪtər/**

The ? : operator, read "if, then, else": condition ? valueIfTrue : valueIfFalse picks one of two values in one line.

## What does **Ternary Operator** do in JavaScript?

**Ternary Operator** — The ?: operator, which chooses one of two values from a condition.

```javascript
const label = stock > 0 ? "Available" : "Sold out";
```

## In a sentence

- “The **ternary operator** in isOpen ? "Open" : "Closed" picks the word for the shop sign.”

Level: Apprentice · [More JavaScript terms at this level](https://www.ask-codey.com/glossary?category=javascript&level=2)

Updated: November 9, 2026

## In other subjects

- [Ternary Operator in C#](https://www.ask-codey.com/glossary/ternary-operator-c-style)
- [Ternary Operator in Java](https://www.ask-codey.com/glossary/ternary-operator)
- [Ternary Operator in Java](https://www.ask-codey.com/glossary/ternary-operator-java)

Source: https://www.ask-codey.com/glossary/ternary-operator-javascript-2
