js of loop code example
Example 1: 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 2: javascript for of
const array = ['hello', 'world', 'of', 'Corona'];
for (const item of array) {
console.log(item);
}
Example 3: javascript for of loop
for (variable of iterable) {
statement
}
Example 4: for in and for of in js
const iterable = [10, 20, 30];
for (const value of iterable) {
console.log("fef"+value);
}
Example 5: use these instead of a for loop javascript
const array = [1,2,3,4,5];const evenNumbers = array.filter(function(elem) {