### JS?`var`與`let`
這兩個關鍵字唯一的區別是,`var`的作用域在最近的函數塊中,而`let`的作用域在最近的塊語句中——它可以是一個函數、一個for循環,或者一個if語句塊。
```
var a = 5;
var b = 10;
if (a === 5) {
let a = 4; // The scope is inside the if-block
var b = 1; // The scope is inside the function
console.log(a); // 4
console.log(b); // 1
}
console.log(a); // 5
console.log(b); // 1
```
一般來說,`let`是塊作用域,`var`是函數作用域。