how to iterate through a list in javascript

JavaScript
String[] myStringArray = {"Hello", "World"};
for (String s : myStringArray)
{
    // Do something
}<script> 
index = 0; 
array = [ 1, 2, 3, 4, 5, 6 ]; 
  
array.forEach(myFunction); 
function myFunction(item, index) 
{ 
    console.log(item); 
}</script>  var i;
for (i = 0; i < cars.length; i++) { 
  text += cars[i] + "<br>";

 } 
Source

Also in JavaScript: