---
description: 🚧 under construction
---

# export

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

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

Every module can have <mark style="color:yellow;">**two different types**</mark> of export, [**named export**](export/named) and [**default export**](export/default). 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/named "mention")
* [default](export/default "mention")
{% endtab %}

{% tab title="👥 相關" %}
* [import](import "mention")
* [..](.. "mention")
* ⛔ [<mark style="color:red;">**SyntaxError**</mark>](../../err/syntax)：[<mark style="color:yellow;">**Named export 'xxx' not found**</mark>](../../err/syntax/named-export-not-found):exclamation:
{% endtab %}

{% tab title="📗 參考" %}
* [ ] [javascript-the-definitive-guide](../../../master/ref/javascript-the-definitive-guide "mention") ⟩&#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 %}
