iterate through the array javascript code example
Example 1: javascript loop through array
var colors = ["red","blue","green"];
colors.forEach(function(color) {
console.log(color);
});
Example 2: javascript loop through array
var myStringArray = ["Hello","World"];
var arrayLength = myStringArray.length;
for (var i = 0; i < arrayLength; i++) {
console.log(myStringArray[i]);
}
Example 3: how to iterate array in javascript
array = [ 1, 2, 3, 4, 5, 6 ];
for (let i = 0; i < array.length ;i++) {
array[i]
}