iterating over an array javascript code example
Example 1: javascript iterate array
var txt = "";
var numbers = [45, 4, 9, 16, 25];
numbers.forEach(function(value, index, array) {
txt = txt + value + "<br>";
});
Example 2: iterate array javascript
array = [ 1, 2, 3, 4, 5, 6 ];
for (index = 0; index < array.length; index++) {
console.log(array[index]);
}
Example 3: javascript foreach index
users.forEach((user, index)=>{
console.log(index);
});
Example 4: javascript iterate array
String[] myStringArray = {"Hello", "World"};
for (String s : myStringArray)
{
}