---
description: a var/let/const in global scope.
---

# global variable

[JS](../..) ⟩ [scope](..) ⟩ [global]() ⟩ variable

{% hint style="success" %}
a [var](../../variable/declare/var "mention")/ [let](../../variable/declare/let "mention") / [const](../../variable/declare/const "mention") variable <mark style="color:yellow;">**declared**</mark> in the [](<> "mention").
{% endhint %}

{% tabs %}
{% tab title="⭐️ 重點" %}
{% hint style="warning" %}
* [prop](object/prop "mention") is also exposed as <mark style="color:purple;">**global variable**</mark>.
* <mark style="color:purple;">**global variables**</mark> <mark style="color:red;">**do**</mark>**&#x20;**<mark style="color:yellow;">**get created**</mark> by [declaring variables](../../variable/declare) in the [](<> "mention").

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

{% hint style="info" %}
[variable](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 ([module](../module "mention")).
{% endhint %}

{% hint style="warning" %}
[dom-element-with-id](dom-element-with-id "mention") is <mark style="color:red;">**automatically**</mark> <mark style="color:yellow;">**registerd**</mark> as [variable](variable "mention")/[prop](object/prop "mention").
{% endhint %}
{% endtab %}

{% tab title="🔴 主題" %}
* [accidental-global-variable-in-sloppy-mode](../../concept/env/js-engine/mode/sloppy-mode/accidental-global-variable-in-sloppy-mode "mention")
* [var](variable/var "mention")
  * [is-global-obj-prop](../../variable/declare/var/is-global-obj-prop "mention"):exclamation:
* [let](variable/let "mention")
  * [shadows-global-object-property](variable/let/shadows-global-object-property "mention"):exclamation:
{% endtab %}

{% tab title="👥 相關" %}
* [accidental-global-variable-in-sloppy-mode](../../concept/env/js-engine/mode/sloppy-mode/accidental-global-variable-in-sloppy-mode "mention")
{% endtab %}
{% endtabs %}
