for of example javascript
Example 1: for of js
let list = [4, 5, 6];
for (let i in list) {
console.log(i); // "0", "1", "2",
}
for (let i of list) {
console.log(i); // "4", "5", "6"
}
Example 2: for of loop in es6
let colors = ['Red', 'Blue', 'Green'];
for (let color of colors){
console.log(color);
}
Example 3: javascript for of
const numbers = [1,2,3,4];
for(const item of numbers){
console.log(item);
}