How to loop through the javascript array with the for loop

Suppose you have created a javascript array and need to loop through all the elements within that array then the best method to use will be either the for or the while loop. In this article we will use the for loop.

var array1 = ["hello", "this", "world"];
for(var i=0; i<array1.length; i++)

The above program will loop through the javascript’s array with the for loop and shows the alert box in every passes of the loop.