iterate over list javascript code example
Example 1: iterate through list javascript
const array = ["hello", "world"];
for (item of array) {
}
Example 2: iterate array in javascrpt
let array = [ 1, 2, 3, 4 ];
for( let element of array ) {
console.log(element);
}
Example 3: iterate over array javascript
var txt = "";
var numbers = [45, 4, 9, 16, 25];
numbers.forEach(myFunction);
function myFunction(value, index, array) {
txt = txt + value + "<br>";
}
Example 4: iterate through array javascript
foreach ($objects as $obj) {
echo $obj->property;
}