if (true) {
var a = 1;
let b = 2;
}
console.log(a); //輸出1
console.log(b); //b is not defined複製程式碼
if (true) {
var a = 1;
let b = 2;
console.log(a); //輸出1
console.log(b); //輸出2 let只能在特定的區域中使用
}
複製程式碼
if (true) {
var a = 1;
let b = 2;
}
console.log(a); //輸出1
console.log(b); //b is not defined複製程式碼
if (true) {
var a = 1;
let b = 2;
console.log(a); //輸出1
console.log(b); //輸出2 let只能在特定的區域中使用
}
複製程式碼