for loop of array js code example
Example 1: javascript loop through array
const myArray = ['foo', 'bar'];
myArray.forEach(x => console.log(x));
//or
for(let i = 0; i < myArray.length; i++) {
console.log(myArray[i]);
}
Example 2: iterate array in javascrpt
let array = [ 1, 2, 3, 4 ]; //Your array
for( let element of array ) {
//Now element takes the value of each of the elements of the array
//Do your stuff, for example...
console.log(element);
}