var 宣告
function test(){
console.log(a)
var a = 1
}
test()
// undefined
let 或 const 宣告
用 let 或 const 宣告一樣有 hoisting 但在賦值之前無法存取,這區間稱為 TDZ
function test(){
console.log(a)
var a = 1
}
test()
// Uncaught ReferenceError: Cannot access 'a' before initialization


![[Week 2] JavaScript - 邏輯運算與位元運算](https://static.coderbridge.com/images/covers/default-post-cover-3.jpg)