---
title: "Discussion on \"JavaScript - Hoisting 提升\" | Hashnode"
description: "Discussion on \"JavaScript - Hoisting 提升\". Hoisting 是怎麼發生的？\n\n變數和函數的宣告會在編譯階段就被放入記憶體，但實際位置和程式碼中完全一樣。\n\n從這段 MDN 對於 hoisting 的說明大概可以了解到，Javascript 在執行程式碼之前會先進行編譯，而在編譯的過程中會將變數宣告以及函式宣告提升 (hoist) 到該 scope 的頂端，但需注意這邊並非實際改動程式碼的位置。\n\nJS 在運作時是分成「編譯」和「執行」兩個步驟。而 hoisting 是發生在編譯的階段。\n\nJS 在編譯的階段會將變數及函式的宣告處理好（h..."
url: "https://hashnode.com/posts/javascript-hoisting/651bc63db5fbc9a995be1c6a"
---

[Feed](https://hashnode.com/feed) /

Discussion

# [JavaScript - Hoisting 提升](https://yachuh.hashnode.dev/javascript-hoisting?utm_source=hashnode&utm_medium=feed)

Hoisting 是怎麼發生的？ 變數和函數的宣告會在編譯階段就被放入記憶體，但實際位置和程式碼中完全一樣。 從這段 MDN 對於 hoisting 的說明大概可以了解到，Javascript 在執行程式碼之前會先進行編譯，而在編譯的過程中會將變數宣告以及函式宣告提升 (hoist) 到該 scope 的頂端，但需注意這邊並非實際改動程式碼的位置。 JS 在運作時是分成「編譯」和「執行」兩個步驟。而 hoisting 是發生在編譯的階段。 JS 在編譯的階段會將變數及函式的宣告處理好（h...

Oct 3, 2023 · 3 min read · yachuh.hashnode.dev  
Read the article

-   [#javascript](https://hashnode.com/tag/javascript)
-   [#hoisting](https://hashnode.com/tag/hoisting)

## Written by

[Ya Chu](https://hashnode.com/@yachuh)

@yachuh

  
[View profile](https://hashnode.com/@yachuh)

Embarking on the Frontend Development Journey

## Responses

Markdown supported · ⌘↵ to post

No responses yet.
