https://bigfrontend.dev/quiz/var
What does the code snippet below output by console.log
?
function foo() {
console.log(i);
for (var i = 0; i < 3; i++) {
console.log(i);
}
}
foo();
function foo() {
console.log(i); // undefined
for (var i = 0; i < 3; i++) {
console.log(i); // 0, 1, 2
}
}
foo();