# Ternary Operator

The ?: operator, which chooses one of two values from a condition.

## 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";
```

Level: Apprentice · [More JavaScript terms at this level](https://www.ask-codey.com/glossary/subjects/javascript/apprentice)

Updated: October 15, 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
