Array Iteration : Array Loop « Array « JavaScript Tutorial






<HTML>
   <HEAD>
   <TITLE>
   Iteration
   </TITLE>
   </HEAD>
   <BODY>
   <H1>
   <SCRIPT>
      var myArray = new Array(4);
      myArray[0] = "A";
      myArray[1] = "B";
      myArray[2] = "C";
      myArray[3] = "D";
      myArray[6] = "E";
     delete myArray[1]
     for (var i = 0; i < myArray.length; i++){
       if (myArray[i])
        document.write("myArray[" + i + "] = " + myArray[i] + "<br>");
     }     
   </SCRIPT>
   </H1>
   </BODY>
</HTML>








11.5.Array Loop
11.5.1.Use for loop to initialize an array
11.5.2.Output all array element with document.write
11.5.3.Use document.write to output the array content
11.5.4.Use for each loop to change the array element value
11.5.5.Array Iteration