The for...of loop iterates over values in arrays and strings:
let colors = ["red", "green", "blue"]
for (let color of colors) {
console.log(color)
}
// Prints: red, green, blue
let word = "hello"
for (let char of word) {
console.log(char)
}
// Prints: h, e, l, l, o
Use for...of when you need values, not indices. It's cleaner than indexing manually.