for of loops javascript code example
Example 1: javascript loop
let array = ['Item 1', 'Item 2', 'Item 3'];
array.forEach(item => {
console.log(item);
});
Example 2: for of js
let list = [4, 5, 6];
for (let i in list) {
console.log(i);
}
for (let i of list) {
console.log(i);
}
Example 3: for of js
let panier = ['fraise', 'banane', 'poire'];
for (const fruit of panier) {
console.log(panier.indexOf(fruit));
}
Example 4: for of loop javascript
const array1 = ['a', 'b', 'c'];
for (const element of array1) {
console.log(element);
}
Example 5: es6 for-of loop
for (let itme of list) {
...
}