---
title: "Discussion on \"JavaScript - Scope 作用域 & Closure 閉包\" | Hashnode"
description: "Discussion on \"JavaScript - Scope 作用域 & Closure 閉包\". Scope 作用域 留言\n什麼是作用域\n\n「作用域就是一個變數的生存範圍，一旦出了這個範圍，就無法存取到這個變數」。\n\n當我們把變數 a 宣告在 function 中，function 之外的地方都無法取用這個變數：\n// 把變數宣告在 function 中\nfunction test1() {\n    var a = \"hello\"\n}\nconsole.log(a) // Uncaught ReferenceError: a is not defined\n\n但當我們把變數 b 宣告在全域，fu..."
url: "https://hashnode.com/posts/javascript-scope-closure/651bc902f424226bd1d1a1b7"
---

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

Discussion

# [JavaScript - Scope 作用域 & Closure 閉包](https://yachuh.hashnode.dev/javascript-scope-closure?utm_source=hashnode&utm_medium=feed)

Scope 作用域 留言 什麼是作用域 「作用域就是一個變數的生存範圍，一旦出了這個範圍，就無法存取到這個變數」。 當我們把變數 a 宣告在 function 中，function 之外的地方都無法取用這個變數： // 把變數宣告在 function 中 function test1() { var a = "hello" } console.log(a) // Uncaught ReferenceError: a is not defined 但當我們把變數 b 宣告在全域，fu...

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

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

## 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.
