# uninitialized variable

[JS](/web/js.md) ⟩ [variable](/web/js/variable.md) ⟩ uninitialized variable

{% hint style="success" %} <mark style="color:yellow;">**when**</mark> a [let](/web/js/variable/declare/let.md) / [const](/web/js/variable/declare/const.md) / [class](/web/js/val/class.md) is still in its [temporal dead zone](/web/js/variable/access/tdz.md), 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](/web/js/variable/access/tdz.md) refers to the <mark style="color:yellow;">**time window (time period)**</mark> where a [const](/web/js/variable/declare/const.md)/[let](/web/js/variable/declare/let.md) 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](/web/js/variable/declare/const.md)/[let](/web/js/variable/declare/let.md) 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](/web/js/variable/declare/initial-value.md), <mark style="color:red;">**not**</mark> [undefined](/web/js/val/prim/undefined.md) <mark style="color:yellow;">**even**</mark>:exclamation:
  {% endtab %}

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

* [ ] [YDKJS: Scope & Closures (v.2)](/web/master/ref/book/you-dont-know-js-series-v.2/ydkjs-scope-and-closures-v.2.md) ⟩&#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 %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://lochiwei.gitbook.io/web/js/variable/access/uninitialized.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
