This is an old revision of the document!


JavaScript Loops


For x in y


For x of y

Used for strings, arrays, array-like objects

const array1 = ['a', 'b', 'c'];
 
for (const element of array1) {
  console.log(element);
}
 
// output: "a"
// output: "b"
// output: "c"