# uninitialized variable

[JS](../..) ⟩ [variable](..) ⟩ uninitialized variable

{% hint style="success" %}
<mark style="color:yellow;">**when**</mark> a [let](../declare/let "mention") / [const](../declare/const "mention") / [class](../../val/class "mention") is still in its [tdz](tdz "mention"), it is said to be <mark style="color:purple;">**uninitialized**</mark>.
{% endhint %}

{% tabs %}
{% tab title="⭐️ 重點" %}
{% hint style="info" %}
<mark style="color:yellow;">**TDZ**</mark> vs. <mark style="color:purple;">**uninitialized variable**</mark>

* [TDZ](tdz) refers to the <mark style="color:yellow;">**time window (time period)**</mark> where a [const](../declare/const "mention")/[let](../declare/let "mention") variable exists but is still <mark style="color:purple;">**uninitialized**</mark> (and <mark style="color:red;">**cannot**</mark>**&#x20;**<mark style="color:yellow;">**be accessed**</mark> in any way).
* <mark style="color:purple;">**uninitialized variable**</mark> refers to the [const](../declare/const "mention")/[let](../declare/let "mention") variable itself.

they are two sides of the same coin.
{% endhint %}
{% endtab %}

{% tab title="👥 相關" %}
* <mark style="color:purple;">**uninitialized variable**</mark> has <mark style="color:red;">**no**</mark> [initial-value](../declare/initial-value "mention"), <mark style="color:red;">**not**</mark> [undefined](../../val/prim/undefined "mention") <mark style="color:yellow;">**even**</mark>:exclamation:
{% endtab %}

{% tab title="📗 參考" %}
* [ ] [ydkjs-scope-and-closures-v.2](../../../master/ref/book/you-dont-know-js-series-v.2/ydkjs-scope-and-closures-v.2 "mention") ⟩&#x20;
  * [ ] [Ch. 1: What's the Scope?](https://github.com/getify/You-Dont-Know-JS/blob/2nd-ed/scope-closures/ch1.md#chapter-1-whats-the-scope) ⟩ [Hoisting](https://github.com/getify/You-Dont-Know-JS/blob/2nd-ed/scope-closures/ch1.md#hoisting)
  * [ ] Ch. 5 > [Uninitialized Variables (aka, TDZ)](https://github.com/getify/You-Dont-Know-JS/blob/2nd-ed/scope-closures/ch5.md#uninitialized-variables-aka-tdz)
{% endtab %}

{% tab title="📘 手冊" %}
* [ ] [temporal dead zone](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/let#temporal_dead_zone_tdz)
{% endtab %}
{% endtabs %}
