> 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/vs-declare.md).

# statement vs. declaration

🚧 施工中

[JS](/web/js.md) ⟩ [grammar](/web/js/grammar.md) ⟩ statement vs. declaration

{% hint style="success" %}
[*statements*](https://tc39.es/ecma262/#prod-Statement) and [*declarations*](https://tc39.es/ecma262/#prod-Declaration) are <mark style="color:yellow;">**two**</mark>**&#x20;**<mark style="color:red;">**disjoint**</mark>**&#x20;**<mark style="color:yellow;">**sets**</mark> of grammars.&#x20;

* the following are (9) [declaration](/web/js/grammar/declare.md)s:
  * [`let`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/let), [`const`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/const)
  * [`function`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/function), [`function*`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/function*)
  * [`async function`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/async_function), [`async function*`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/async_function*)
  * [`class`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/class)
  * [`export`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/export), [`import`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/import) (can only appear at the top-level of a [module](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Modules))
* <mark style="color:yellow;">**everything else**</mark> in this [list](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements#statements_and_declarations_by_category) is a [statement](/web/js/grammar/statement.md).
  {% endhint %}

{% tabs %}
{% tab title="⭐️ 重點" %}
{% hint style="warning" %} <mark style="color:purple;">**statement vs. declaration**</mark>

* [var](/web/js/variable/declare/var.md) is a [statement](/web/js/grammar/statement.md):exclamation:
* [let](/web/js/variable/declare/let.md)/[const](/web/js/variable/declare/const.md) is a [declaration](/web/js/grammar/declare.md).&#x20;

👉 [statement expected❗️](/web/js/grammar/statement/statement-expected.md):exclamation:
{% endhint %}

{% hint style="info" %}

* <mark style="color:purple;">**declaration**</mark>： <mark style="color:yellow;">**binding**</mark> [identifier](/web/js/grammar/token/id.md) to [value](/web/js/val.md).
* <mark style="color:purple;">**statement**</mark>： carrying out <mark style="color:yellow;">**actions**</mark>.
  {% endhint %}
  {% endtab %}

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

* [ ] [Difference between statements and declarations](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements#difference_between_statements_and_declarations) ⭐️⭐️⭐️ ❗️❗️❗️
* [ ] ECMA ⟩&#x20;
  * [ ] [Statement](https://tc39.es/ecma262/#prod-Statement)
  * [ ] [Declaration](https://tc39.es/ecma262/#prod-Declaration)
    {% endtab %}
    {% endtabs %}
