Utilizor
Contact Us

For Of Loop

Looping through values.

Examples

Looping Array

Iterating over array values directly.

const cars = ["BMW", "Volvo", "Mini"];
let text = "";
for (let x of cars) {
  text += x + "\n";
}
console.log(text);

Looping String

Iterating over characters in a string.

let language = "JavaScript";
let text = "";
for (let x of language) {
    text += x + "\n";
}
console.log(text);

Test Your Knowledge

JavaScript Quiz

No quiz available for this topic yet.