---
description: the name of a variable/function/property/label/parameter.
---

# identifier

[JS](../..) ⟩ [grammar](..) ⟩ [token]() ⟩ identifier

{% hint style="success" %}
([](<> "mention")) \
the <mark style="color:yellow;">**name**</mark> of a [variable](../../variable "mention") / [func](../../val/func "mention") / [prop](../../val/obj/prop "mention") / [label](../statement/other/label "mention") / [param](../../val/func/param "mention").

* <mark style="color:red;">**case-sensitive**</mark> :exclamation:
* <mark style="color:red;">**must**</mark>**&#x20;**<mark style="color:yellow;">**begin with**</mark>&#x20;
  * <mark style="color:orange;">**letter**</mark> (<mark style="color:blue;">`a...z, A...Z`</mark>, or [Unicode](https://developer.mozilla.org/en-US/docs/Glossary/Unicode) letter&#x73;**)**
  * <mark style="color:orange;">**underscore**</mark> (<mark style="color:blue;">`_`</mark>)
  * <mark style="color:orange;">**dollar sign**</mark> (<mark style="color:blue;">`$`</mark>)&#x20;
  * <mark style="color:red;">**may not**</mark> start with a <mark style="color:yellow;">**digit**</mark> (<mark style="color:blue;">`0-9`</mark>):exclamation:
* <mark style="color:yellow;">**subsequent**</mark>**&#x20;characters** can be <mark style="color:orange;">**digits**</mark> (<mark style="color:blue;">`0...9`</mark>).
{% endhint %}

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

* <mark style="color:yellow;">**registered**</mark> to respective [scope](../../scope "mention") at [compile-time](../../compile/compile-time "mention").
* <mark style="color:yellow;">**created**</mark> at the <mark style="color:yellow;">**beginning**</mark> of the [scope](../../scope "mention") it belongs to, <mark style="color:yellow;">**every time**</mark> that <mark style="color:yellow;">**scope**</mark> is <mark style="color:yellow;">**entered**</mark> (at [runtime](../../compile/runtime "mention")).
{% endhint %}

{% hint style="danger" %}
<mark style="color:red;">**avoid**</mark> using [reserved](keyword/reserved "mention") as [id](id "mention"):exclamation:\
(at least for [variable](../../variable "mention")/[func](../../val/func "mention")/[label](../statement/other/label "mention"))&#x20;
{% endhint %}

{% hint style="success" %}
the [name](../../val/obj/prop/name "mention") in [dot-notation-.](../../val/obj/prop/access/dot-notation-. "mention") <mark style="color:green;">**can**</mark>**&#x20;**<mark style="color:yellow;">**be**</mark> a [reserved](keyword/reserved "mention"):exclamation:
{% endhint %}

{% hint style="success" %}
there are <mark style="color:yellow;">**5 categories**</mark> of <mark style="color:purple;">**identifier**</mark> names:

* <mark style="color:red;">**not**</mark> [keyword](keyword "mention")s (<mark style="color:green;">**always**</mark>**&#x20;**<mark style="color:yellow;">**allowed**</mark> as <mark style="color:purple;">**identifiers**</mark>)： \
  <mark style="color:blue;">`Math`</mark>, <mark style="color:blue;">`window`</mark>, <mark style="color:blue;">`toString`</mark>, <mark style="color:blue;">`_`</mark> ...
* [keyword](keyword "mention")s：
  * <mark style="color:red;">**never allowed**</mark> as <mark style="color:purple;">**identifiers**</mark>： \
    [reserved](keyword/reserved "mention") (<mark style="color:orange;">**except**</mark> <mark style="color:blue;">`await`</mark>, <mark style="color:blue;">`yield`</mark>)
  * <mark style="color:orange;">**contextually**</mark>**&#x20;**<mark style="color:yellow;">**allowed**</mark> as <mark style="color:purple;">**identifiers**</mark>： \
    namely <mark style="color:blue;">`await`</mark>, <mark style="color:blue;">`yield`</mark>.
  * <mark style="color:orange;">**contextually**</mark> <mark style="color:red;">**disallowed**</mark> as <mark style="color:purple;">**identifiers**</mark>, in [strict mode code](https://262.ecma-international.org/13.0/#sec-strict-mode-code):：\
    `let`, `static`, `implements`, `interface`, `package`, `private`, `protected`, `public`.
  * <mark style="color:yellow;">**always allowed**</mark> as <mark style="color:purple;">**identifiers**</mark>, but <mark style="color:orange;">**also appear as**</mark> [keyword](keyword "mention")s <mark style="color:orange;">**within certain syntactic productions**</mark>, at places where <mark style="color:purple;">**identifier**</mark> is <mark style="color:red;">**not allowed**</mark>: \
    `as`, `async`, `from`, `get`, `meta`, `of`, `set`, `target`.

The term <mark style="color:yellow;">**conditional keyword**</mark>, or <mark style="color:yellow;">**contextual keyword**</mark>, is sometimes used to refer to the keywords that fall in the <mark style="color:yellow;">**last 3 categories**</mark>, and thus can be used as [id](id "mention")s in some contexts and as [keyword](keyword "mention")s in others. :blue\_book:[ECMA](https://262.ecma-international.org/13.0/#sec-keywords-and-reserved-words)
{% endhint %}

{% hint style="warning" %}
`NaN`/`Infinity`/ [undefined](../../val/prim/undefined "mention") are&#x20;

* <mark style="color:red;">**read-only**</mark> [properties](../../val/obj/prop) ([id](id "mention")) of the [object](../../scope/global/object "mention"):exclamation:
* <mark style="color:red;">**not**</mark> [keyword](keyword "mention")s.
{% endhint %}

{% hint style="info" %}
the [id](id "mention") of a [expr](../../val/func/expr "mention") is in <mark style="color:yellow;">**its own**</mark> [implied](../../scope/implied "mention").&#x20;
{% endhint %}

{% hint style="success" %}
<mark style="color:red;">**only**</mark> object's <mark style="color:red;">**configurable**</mark> <mark style="color:yellow;">**properties**</mark> are "<mark style="color:green;">**qualified**</mark>" for "[**delete**](../../val/obj/prop/create/delete)", <mark style="color:yellow;">**other**</mark> <mark style="color:purple;">**identifiers**</mark> are "[**unqualified**](../../val/obj/prop/create/delete/unqualified-for-delete)" ( <mark style="color:red;">**can't**</mark>**&#x20;**<mark style="color:yellow;">**delete them**</mark>:exclamation:). 📘 [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Delete_in_strict_mode#what_went_wrong)
{% endhint %}
{% endtab %}

{% tab title="🔴 主題" %}
* <mark style="color:yellow;">**types of identifiers**</mark>
  * [undeclared](id/undeclared "mention")
  * [unqualified-for-delete](../../val/obj/prop/create/delete/unqualified-for-delete "mention") - can't be deleted:exclamation:
  * [this](../../scope/global/object/this "mention") - identifier for the [object](../../scope/global/object "mention").
  * [special](id/special "mention")
  * [label](../statement/other/label "mention") of a statement
  * [name](../../val/func/name "mention")
  * [param](../../val/func/param "mention")(s) of a function
  * [name](../../val/obj/prop/name "mention")
* <mark style="color:yellow;">**comparisons**</mark>
  * [vs-string](id/vs-string "mention")
  * [vs-keyword](id/vs-keyword "mention")
* <mark style="color:yellow;">**binding of a value**</mark>
  * [static-binding](id/static-binding "mention")\
    (the [val](../../val "mention") of an [id](id "mention") is <mark style="color:yellow;">**predetermined**</mark> at [compile-time](../../compile/compile-time "mention"))
  * [dynamic-binding](id/dynamic-binding "mention")\
    (the [val](../../val "mention") of an [id](id "mention") is <mark style="color:red;">**not determined**</mark> until [runtime](../../compile/runtime "mention"))
{% endtab %}

{% tab title="👥 相關" %}
* part of [..](.. "mention")
* the [id](id "mention") of a [expr](../../val/func/expr "mention") is in <mark style="color:yellow;">**its own**</mark> [implied](../../scope/implied "mention").&#x20;
* :no\_entry:[delete-of-an-unqualified-identifier-in-strict-mode](../../err/syntax/delete-of-an-unqualified-identifier-in-strict-mode "mention") - variables can't be deleted:exclamation:
* :no\_entry:[delete](../../variable/delete "mention")
* :no\_entry: the "<mark style="color:blue;">`prop`</mark>" part of [dot-notation-.](../../val/obj/prop/access/dot-notation-. "mention") <mark style="color:red;">**must**</mark>**&#x20;**<mark style="color:yellow;">**be**</mark> an [id](id "mention"):exclamation:
{% endtab %}

{% tab title="📗 參考" %}
* [ ] [ydkjs-scope-and-closures-v.2](../../../master/ref/book/you-dont-know-js-series-v.2/ydkjs-scope-and-closures-v.2 "mention") ⟩ Ch. 5 ⟩ [When Can I Use a Variable?](https://github.com/getify/You-Dont-Know-JS/blob/2nd-ed/scope-closures/ch5.md#when-can-i-use-a-variable)
{% endtab %}

{% tab title="📘 手冊" %}
* [ ] [Identifier](https://developer.mozilla.org/en-US/docs/Glossary/Identifier)
* [ ] ECMA ⟩ [13. Expressions](https://262.ecma-international.org/13.0/#sec-ecmascript-language-expressions) ⟩ [13.1 Identifiers](https://262.ecma-international.org/13.0/#prod-Identifier)
* [ ] [Statements and declarations](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements) ⟩ [Others](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements#others) ⟩[ label](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/label)&#x20;
{% endtab %}
{% endtabs %}
