js for of array code example
Example 1: for of array javascript
let colors = ['red', 'green', 'blue'];
for (const color of colors){
console.log(color);
}
Example 2: javascript for of
const array = ['hello', 'world', 'of', 'Corona'];
for (const item of array) {
console.log(item);
}
Example 3: javascript for of
const numbers = [1,2,3,4];
for(const item of numbers){
console.log(item);
}
Example 4: iterate over array javascript
var txt = "";
var numbers = [45, 4, 9, 16, 25];
numbers.forEach(myFunction);
function myFunction(value, index, array) {
txt = txt + value + "<br>";
}