> 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/token/punctuator/semicolon/automatic-semicolon-insertion.md).

# automatic semicolon insertion

🚧 施工中

[JS](/web/js.md) ⟩ [grammar](/web/js/grammar.md) ⟩ [token](/web/js/grammar/token.md) ⟩ [semicolon](/web/js/grammar/token/punctuator/semicolon.md) ⟩ automatic insertion

{% hint style="warning" %}
There are <mark style="color:yellow;">**three cases**</mark> when [semicolon (;)](/web/js/grammar/token/punctuator/semicolon.md) are automatically inserted:

🚧
{% endhint %}

{% tabs %}
{% tab title="🧨 雷區" %}
{% hint style="danger" %}

* <mark style="color:purple;">**ASI**</mark> would <mark style="color:red;">**only be triggered**</mark> if a <mark style="color:yellow;">**line break**</mark> separates [token](/web/js/grammar/token.md)s that would otherwise produce <mark style="color:red;">**invalid syntax**</mark>.&#x20;
* If the <mark style="color:yellow;">**next**</mark> [token](/web/js/grammar/token.md) can be parsed as <mark style="color:yellow;">**part of**</mark> a <mark style="color:green;">**valid structure**</mark>, [semicolon (;)](/web/js/grammar/token/punctuator/semicolon.md) would <mark style="color:red;">**not**</mark> be inserted. &#x20;
  {% endhint %}

```
// Some code 🚧
```

{% endtab %}

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

* [return](/web/js/grammar/statement/flow/jump/return.md) is affected by <mark style="color:purple;">**automatic semicolon insertion**</mark>.
  {% endtab %}

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

* [ ] lexical grammar ⟩ [automatic semicolon insertion](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Lexical_grammar#automatic_semicolon_insertion)
  {% endtab %}
  {% endtabs %}
