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

# module scope

[JS](..) ⟩ [concepts](../../browser/concepts) ⟩ [scope]() ⟩ module

{% hint style="success" %}
[](<> "mention") for code running <mark style="color:yellow;">**in**</mark> [module](../module "mention") <mark style="color:yellow;">**mode**</mark>.
{% endhint %}

{% tabs %}
{% tab title="⭐️ 重點" %}
{% hint style="warning" %}
in a [module](../module "mention") there's <mark style="color:red;">**no**</mark> "<mark style="color:purple;">**module-wide scope**</mark>**&#x20;**<mark style="color:yellow;">**object**</mark>" for these <mark style="color:yellow;">**top-level**</mark> [declare](../grammar/declare "mention")s to be added to as [prop](../val/obj/prop "mention").

( 👉 compare： [is-global-obj-prop](../variable/declare/var/is-global-obj-prop "mention"))
{% endhint %}

{% hint style="warning" %}
[variable](global/variable "mention")s <mark style="color:red;">**don't**</mark>**&#x20;**<mark style="color:yellow;">**get created**</mark> by [declaring variables](../variable/declare) in the [top-level](top-level "mention") of a module (<mark style="color:purple;">**module scope**</mark>).
{% endhint %}
{% endtab %}

{% tab title="👥 相關" %}
* [module](../module "mention")
{% endtab %}

{% tab title="🗺️ 圖表" %}
<div><figure><img src="https://ringojs.org/documentation/images/modulescope.png" alt=""><figcaption><p>✅ each module has its own scope </p></figcaption></figure> <figure><img src="https://ringojs.org/documentation/images/scriptscope.png" alt=""><figcaption><p>❌ global object shared by all scripts</p></figcaption></figure></div>
{% endtab %}

{% tab title="📗 參考" %}
* [ ] ringojs ⟩ [Understanding module and global scope](https://ringojs.org/documentation/module_and_global_scope/) ⭐️
* [ ] [ydkjs-scope-and-closures-v.2](../../master/ref/book/you-dont-know-js-series-v.2/ydkjs-scope-and-closures-v.2 "mention") ⟩ Ch. 4 ⟩ [ES Modules](https://github.com/getify/You-Dont-Know-JS/blob/2nd-ed/scope-closures/ch4.md#es-modules-esm)
{% endtab %}

{% tab title="📘 手冊" %}
* [ ] [Scope](https://developer.mozilla.org/en-US/docs/Glossary/Scope)
{% endtab %}
{% endtabs %}
