> 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/module/es/export.md).

# export

🚧 under construction

* [JS](/web/js.md) ⟩ [module](/web/js/module.md) ⟩ [ES](/web/js/module/es.md) ⟩ export
* [JS](/web/js.md) ⟩ [grammar](/web/js/grammar.md) ⟩ [declaration](/web/js/grammar/declare.md) ⟩ export&#x20;

{% hint style="success" %} <mark style="color:yellow;">**(**</mark>[directive](/web/js/grammar/directive.md) <mark style="color:yellow;">**or**</mark> [declaration](/web/js/grammar/declare.md):question:<mark style="color:yellow;">**)**</mark>&#x20;

Every module can have <mark style="color:yellow;">**two different types**</mark> of export, [**named export**](/web/js/module/es/export/named.md) and [**default export**](/web/js/module/es/export/default.md). You can have <mark style="color:orange;">**multiple**</mark>**&#x20;**<mark style="color:yellow;">**named exports**</mark> per module but <mark style="color:red;">**only one**</mark>**&#x20;**<mark style="color:yellow;">**default export**</mark>.&#x20;

```javascript
export { PI, TAU };                      // named exports
export default class SomeClass { ... }   // default export
```

{% endhint %}

{% tabs %}
{% tab title="⭐️ 重點" %}
{% hint style="success" %}
Export declarations are not subject to [temporal dead zone](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/let#temporal_dead_zone_tdz) rules. You can declare that the module exports `X` before the name `X` itself is declared.

```javascript
export { x };    // export before declaration (it's OK)
const x = 1;
```

{% endhint %}
{% endtab %}

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

* [named export](/web/js/module/es/export/named.md)
* [default export](/web/js/module/es/export/default.md)
  {% endtab %}

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

* [import](/web/js/module/es/import.md)
* [module](/web/js/module.md)
* ⛔ [<mark style="color:red;">**SyntaxError**</mark>](/web/js/err/syntax.md)：[<mark style="color:yellow;">**Named export 'xxx' not found**</mark>](/web/js/err/syntax/named-export-not-found.md):exclamation:
  {% endtab %}

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

* [ ] [JavaScript: The Definitive Guide](/web/master/ref/javascript-the-definitive-guide.md) ⟩&#x20;
  * [ ] 5.7.4 import and export&#x20;
  * [ ] 10.3
    {% endtab %}

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

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