in javascript, why are we able to use variables that havent been declared (i.e. const, let, var) in the for loop? example code below:
function testFunc(items) {
for (item of items) {
console.log(item)
}
}
I would expect the above code to error out. Dont we need to declare the variable with one of the const, let and var keywords? Example below:
function testFunc(items) {
for (const item of items) {
console.log(item)
}
}