Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

javascript for loops in vs of

let myArray = ["a", "b", "c"];

// for...in iterates over properties (like index)
for (let i in myArray){
  console.log(i); // → 0, 1, 2
} 

// for...of iterates over values
for (let i of myArray){
  console.log(i); // → a, b, c
} 
Source by developer.mozilla.org #
 
PREVIOUS NEXT
Tagged: #javascript #loops
ADD COMMENT
Topic
Name
5+4 =