var array in for loop create code example
Example 1: js loop through array
for (const color of colors){
console.log(color);
}
const array = ["one", "two", "three"]
array.forEach(function (item, index) {
console.log(item, index);
});
for (var i = 0; i < arrayLength; i++) {
console.log(myStringArray[i]);
}
Example 2: loop through javascript array
let colors = ['red', 'green', 'blue'];
for (const color of colors){
console.log(color);
}
Example 3: javascript loop and array
var array = ["hello","world"];
array.forEach(item=>{
console.log(item);
});