# trailing comma

* [JS](../../..) ⟩ [grammar](../..) ⟩ [token](..) ⟩ [literal]() ⟩ trailing comma

{% hint style="success" %}
<mark style="color:red;">**single**</mark> <mark style="color:purple;">**trailing comma**</mark>  is <mark style="color:green;">**allowed**</mark> in [arr](../../../val/builtin/arr/create/arr "mention") <mark style="color:yellow;">**/**</mark> [obj](../../../val/obj/create/obj "mention").

```javascript
let arr = [ 1, 2, 3, ];         // 💡 single trailing comma allowed, 
//                 ^            //     won't create "undefined element".

let obj = { name: 'Joy', age: 17, }
//                               ^ <---- trailing comma
```

:floppy\_disk: replit：[undefined elements in array literal](https://replit.com/@pegasusroe/undefined-elements-in-array-literal#index.js)
{% endhint %}

{% tabs %}
{% tab title="📘 手冊" %}
* [ ] [Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)
* [ ] [Expressions and operators](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators) ⟩&#x20;
* [ ] [Lexical Grammar](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Lexical_grammar) ⟩ [Array Literals](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Lexical_grammar#array_literals)
{% endtab %}

{% tab title="📗 參考" %}
* [ ] [javascript-the-definitive-guide](../../../../master/ref/javascript-the-definitive-guide "mention") ⟩&#x20;
  * [ ] 4.2：Object / Array Initializers
{% endtab %}
{% endtabs %}
