Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

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
}
Source by developer.mozilla.org #
 
PREVIOUS NEXT
Tagged: #Difference #Between #Statement
ADD COMMENT
Topic
Name
3+6 =