> 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/val/prim/symbol.md).

# Symbol

[JS](/web/js.md) ⟩ [value](/web/js/val.md) ⟩ [primitive](/web/js/val/prim.md) ⟩ symbol

{% hint style="success" %}
returns a [primitive](/web/js/val/prim.md) <mark style="color:yellow;">**value**</mark> that's guaranteed to be <mark style="color:yellow;">**unique**</mark>.

```javascript
const unique = Symbol()    // ⭐️ not `new Symbol()`❗️ 
let obj = {
    [unique]: <value>,     // symbol used as a computed property name
};
```

{% endhint %}

{% tabs %}
{% tab title="⭐️ 重點" %}
{% hint style="warning" %} <mark style="color:purple;">**Symbols**</mark>&#x20;

* <mark style="color:red;">**only**</mark>**&#x20;**<mark style="color:yellow;">**used as**</mark> [**(computed) property names**](/web/js/val/obj/prop/name/computed.md).:exclamation:
* are [**primitive**](/web/js/val/prim.md) values, <mark style="color:red;">**not**</mark>**&#x20;**<mark style="color:yellow;">**objects**</mark>, <mark style="color:purple;">**Symbol()**</mark> <mark style="color:yellow;">**is**</mark>**&#x20;**<mark style="color:red;">**not**</mark> a [**constructor**](/web/js/val/func/constructor.md).:exclamation:
* <mark style="color:red;">**can't**</mark>**&#x20;**<mark style="color:yellow;">**invoke with**</mark> [**new**](/web/js/val/obj/create/new.md):exclamation:
  {% endhint %}
  {% endtab %}

{% tab title="🔴 主題" %}

* [Symbol.iterator](/web/js/val/prim/symbol/iterator.md) - name of a required method for iterables.
  {% endtab %}

{% tab title="👥 相關" %}

* <mark style="color:purple;">**Symbols**</mark> can be used as [**computed property names**](/web/js/val/obj/prop/name/computed.md).
* [object literal](/web/js/val/obj/create/obj.md)
  {% endtab %}

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

* [ ] [JavaScript: The Definitive Guide](/web/master/ref/javascript-the-definitive-guide.md) ⟩&#x20;
  * [ ] 3.6 Symbols
  * [ ] 6.10.3 Symbols as Property Names
    {% endtab %}

{% tab title="📘 手冊" %}

* [Symbol](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol)
  {% endtab %}
  {% endtabs %}
