---
description: 🚧 under construction -> example
---

# let/const/class hoisting

[JS](../../..) ⟩ [scope](../..) ⟩ [hoisting](..) ⟩ let/const/class

{% hint style="success" %}
with [let](../../../variable/declare/let "mention") <mark style="color:yellow;">**/**</mark> [const](../../../variable/declare/const "mention") <mark style="color:yellow;">**/**</mark> [class](../../../val/class "mention") [**declaration**](../../../grammar/declare)：

* [id](../../../grammar/token/id "mention")： <mark style="color:yellow;">**hoisted**</mark> to <mark style="color:yellow;">**top**</mark> of its [..](../.. "mention").
* [val](../../../val "mention")： <mark style="color:red;">**uninitialized**</mark>:exclamation:(<mark style="color:yellow;">**referencing**</mark> it <mark style="color:red;">**before init**</mark> <mark style="color:yellow;">**causes**</mark> [<mark style="color:red;">**ReferenceError**</mark>](../../../err/ref/cannot-access-before-init))
{% endhint %}

{% tabs %}
{% tab title="👥 相關" %}
* compare： [var](var "mention"), [function](../function "mention")
{% endtab %}

{% tab title="💈範例" %}
* replit：let const hoisting

```javascript
```
{% 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](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 ⟩ [Hoisting: Declaration vs. Expression](https://github.com/getify/You-Dont-Know-JS/blob/2nd-ed/scope-closures/ch5.md#hoisting-declaration-vs-expression)
{% endtab %}
{% endtabs %}
