js for in loop array code example
Example 1: loop array javascript
var colors = ['red', 'green', 'blue'];
colors.forEach((color, colorIndex) => {
console.log(colorIndex + ". " + color);
});
Example 2: loop array in javascript
var colors = ["red", "green", "blue"];
for(var i = 0; i < colors.length; i++){
console.log(colors[i]);
}
Example 3: javascript loop and array
var array = ["hello","world"];
array.forEach(item=>{
console.log(item);
});