javascript loop through all elements array code example
Example 1: loop through javascript array
let colors = ['red', 'green', 'blue'];
for (const color of colors){
console.log(color);
}
Example 2: iterate through array js
let arbitraryArr = [1, 2, 3];
// below I choose let, but var and const can also be used
for (let arbitraryElementName of arbitraryArr) {
console.log(arbitraryElementName);
}