Answers for "Difference Between for...of and for...in Statement"

1

Difference Between for...of and for...in Statement

const 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
}
Posted by: Guest on August-12-2021

Code answers related to "Difference Between for...of and for...in Statement"

Code answers related to "Javascript"

Browse Popular Code Answers by Language