> For the complete documentation index, see [llms.txt](https://lochiwei.gitbook.io/web/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://lochiwei.gitbook.io/web/js/grammar/op/binary/comma-operator.md).

# comma operator (,)

[JS](/web/js.md) ⟩ [statement](/web/js/grammar/statement.md) ⟩ [expression](/web/js/grammar/statement/expr.md) ⟩ [operator](/web/js/grammar/op.md) ⟩ [binary](/web/js/grammar/op/binary.md) ⟩ comma (,)

{% hint style="success" %}
([operator](/web/js/grammar/op.md))

```javascript
<expr1>, <expr2>    // both expressions evaluated, last returned.
// ⭐️ expressions can't be declarations❗️
```

{% endhint %}

{% tabs %}
{% tab title="⭐️ 重點" %}
{% hint style="info" %} <mark style="color:purple;">**`','`**</mark> [<mark style="color:yellow;">**punctuator**</mark>](/web/js/grammar/token/punctuator.md) used in [**declaration**](/web/js/variable/declare.md) syntax and <mark style="color:purple;">**comma operator**</mark>.

```javascript
for(let i=0, j=10; i < j; i++, j-- ) { ... }
//  ╰──── 1 ────╯         ╰── 2 ──╯
// 1. let declaration
// 2. comma operator
```

{% endhint %}
{% endtab %}

{% tab title="📗 參考" %}

* [ ] JS.info ⟩ [comma operator](https://javascript.info/operators#comma)
* [ ] [JavaScript: The Definitive Guide](/web/master/ref/javascript-the-definitive-guide.md) ⟩ 4.13.7 The comma Operator (,)
  {% endtab %}

{% tab title="🗣 討論" %}

* [Does JavaScript have non-shortcircuiting boolean operators?](https://stackoverflow.com/questions/5652363/does-javascript-have-non-shortcircuiting-boolean-operators)
  {% endtab %}

{% tab title="✨ 範例" %}

* codepen ⟩ [non-shortcircuiting "or" ?](https://codepen.io/lochiwei/pen/LYjpYqv?editors=0012)
  {% endtab %}
  {% endtabs %}
