https://bigfrontend.dev/quiz/Hoisting-IV
What does the code snippet below output by console.log
?
let foo = 10;
function func1() {
console.log(foo);
var foo = 1;
}
func1();
function func2() {
console.log(foo);
let foo = 1;
}
func2();
let foo = 10;
function func1() {
console.log(foo); // undefined
var foo = 1;
}
func1();
function func2() {
console.log(foo); // Error
let foo = 1;
}
func2();