const myArray = ['foo', 'bar']; myArray.forEach(x => console.log(x)); //or for(let i = 0; i < myArray.length; i++) { console.log(myArray[i]); }
int[] numbers = {1,2,3,4,5}; for (int i = 0; i < numbers.length; i++) { System.out.println(i); }
let fruits = ['Apple', 'Banana']; fruits.forEach(function(item, index, array) { console.log(item, index); }); // Apple 0 // Banana 1
foreach ($objects as $obj) { echo $obj->property; }