---
description: 🚧 施工中
---

# contextual keyword

[JS](../../..) ⟩ [grammar](../..) ⟩ [keyword]() ⟩ contextual keyword

{% hint style="success" %}
[](<> "mention") that <mark style="color:green;">**can**</mark>/<mark style="color:red;">**cannot**</mark> be used as [id](../id "mention") <mark style="color:orange;">**in some contexts**</mark>.

```javascript
// 18 contextual keywords
as async from get implements interface let of 
package private protected public set static target
await yield    // ⭐️ reserved words
```
{% endhint %}

{% hint style="info" %}
* <mark style="color:orange;">**contextually**</mark>**&#x20;**<mark style="color:yellow;">**allowed**</mark> as [id](../id "mention")： (2)
  * <mark style="color:blue;">`await`</mark> -  reserved only inside [functions](../../../async/async/functions "mention")s and [module](../../../module "mention")s.
  * <mark style="color:blue;">`yield`</mark> -&#x20;
* <mark style="color:orange;">**contextually**</mark> <mark style="color:red;">**disallowed**</mark> as [id](../id "mention"), in [strict mode code](https://262.ecma-international.org/13.0/#sec-strict-mode-code)：(8)
  * [let](../../../variable/declare/let "mention")
  * `static`, `implements`, `interface`, `package`, `private`, `protected`, `public`.
* <mark style="color:yellow;">**mostly allowed**</mark> as [id](../id "mention"), but <mark style="color:orange;">**also appear as**</mark> [](<> "mention")s <mark style="color:orange;">**within certain syntactic productions**</mark>, at places where [id](../id "mention") is <mark style="color:red;">**not allowed**</mark>：(8)
  * `as`, `from`, `get`, `meta`, `of`, `set`, `target`.&#x20;
  * [async](../../../async/async "mention") -  can be used as a [variable](../../../variable "mention") <mark style="color:yellow;">**name**</mark> or [statement](../../statement "mention") <mark style="color:yellow;">**label**</mark> without restriction.
{% endhint %}

{% tabs %}
{% tab title="⭐️ 重點" %}
{% hint style="danger" %}
<mark style="color:blue;">await</mark>, <mark style="color:blue;">yield</mark> are [reserved](reserved "mention") and <mark style="color:purple;">**contextual keywords**</mark> at the same time.
{% endhint %}

{% hint style="warning" %}
* `NaN`, `Infinity`, and `undefined` are：
  * <mark style="color:red;">**not**</mark> <mark style="color:purple;">**reserved keywords**</mark>.
  * <mark style="color:yellow;">**immutable**</mark> & <mark style="color:yellow;">**read-only**</mark> [properties](../../../val/obj/prop) of the [object](../../../scope/global/object "mention").
* JavaScript <mark style="color:red;">**does not throw**</mark> any errors if you declare them in the [global scope](https://www.tektutorialshub.com/javascript/scope-in-javascript/).

:green\_book:[TeckTutorialHub](https://www.tektutorialshub.com/javascript/javascript-keywords-reserved-words/)
{% endhint %}
{% endtab %}

{% tab title="💈範例" %}
* replit：[reserved words](https://replit.com/@pegasusroe/reserved-words#index.js)

```javascript
// 18 contextual keywords
as async from get implements interface let of 
package private protected public set static target
await yield    // ⭐️ reserved words
```
{% endtab %}

{% tab title="📘 手冊" %}
* [ ] [Lexical grammar](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Lexical_grammar) ⟩ [keywords](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Lexical_grammar#keywords) ⟩ [reserved words](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Lexical_grammar#reserved_words)
* [ ] [SyntaxError: "x" is a reserved identifier](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Reserved_identifier)
* [ ] ECMA spec ⟩ [12.6.2 Keywords and Reserved Words](https://262.ecma-international.org/13.0/#sec-keywords-and-reserved-words) ⟩ [Reserved Words](https://262.ecma-international.org/13.0/#prod-ReservedWord) ⭐️
{% endtab %}

{% tab title="📗 參考" %}
* [ ] TeckTutorialHub ⟩ [JavaScript Keywords & Reserved Words](https://www.tektutorialshub.com/javascript/javascript-keywords-reserved-words/) ⭐️
{% endtab %}

{% tab title="🚧" %}
* [ ] undefined
* [ ] NaN
* [ ] Infinity
{% endtab %}
{% endtabs %}
