I have a snippet which I'm experimenting the for...of
statement on it:
let arr = [3, 5, 7];
arr.foo = "hello";
for (let i in arr) {
console.log(i); // logs "0", "1", "2", "foo"
}
for (let i of arr) {
console.log(i); // logs "3", "5", "7"
}
My Question is that for...of
should run on iterable values, right? so why the second for
doesn't print "hello"
?