how o loop over arrray of elements javascript 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: javascript iterate through for loop
var myStringArray = ["Hello","World"];
var arrayLength = myStringArray.length;
for (var i = 0; i < arrayLength; i++) {
console.log(myStringArray[i]);
}