报错:ReferenceError: Cannot access 'X' before initialization
1、以下代码报错:ReferenceError: Cannot access 'age' before initialization
function fn (age){
if (typeof age === 'undefined'){
console.log(age);
let age = 66;
}
}
fn();
2、解决办法:
将let换成var,let只能声明一次