---
description: operation with 3 operands.
---

# ternary operator

[JS](../..) ⟩ [statement](../statement) ⟩ [expression](../statement/expr) ⟩ [operator]() ⟩ ternary

{% hint style="success" %}
([](<> "mention")) an operation with <mark style="color:yellow;">**3 operands**</mark>.  :point\_right: [table-of-operators](table-of-operators "mention")&#x20;

```javascript
condition ? a : b    // returns a if condition true, b otherwise.
```

:u6307: <mark style="color:yellow;">**synonyms**</mark>： [conditional-operator](ternary/conditional-operator "mention")
{% endhint %}

{% tabs %}
{% tab title="👥 相關" %}
* [unary](unary "mention")
* [binary](binary "mention")
{% endtab %}
{% endtabs %}
