Can someone please explain why the line console.log(i);
prints 3. From what I understand, “i” is declared within the scope of just the for loop and shouldn’t be available outside it not outside it.
var numArray = [];
for (var i = 0; i < 3; i++) {
numArray.push(i);
}
console.log(numArray);
// returns [0, 1, 2]
console.log(i);
// returns 3