Use for statement to loop through all elements in an array : For Loop « Statement « JavaScript Tutorial






<html>
<head>
<title>Use for statement to loop through all elements in an array</title>

</head>
<body>
<P>

<script language="javascript" type="text/javascript">
<!--

var myArray = new Array();
myArray[0] = "AAA";
myArray[1] = "BBB";
myArray[2] = "CCC";
for (var i=0; i<myArray.length; i++) {
  document.write("Element " +i+ " contains: " +myArray[i]+ "<br />");
}

//-->
</script>

</p>

</body>
</html>








3.4.For Loop
3.4.1.for Loops
3.4.2.Using the JavaScript for Loop
3.4.3.For loop with undeclared loop counter
3.4.4.Multiplication Table Generator by using for loop
3.4.5.Use for statement to loop through all elements in an array
3.4.6.Reversed for loop
3.4.7.Set loop step to 5 in for loop
3.4.8.Check the loop counter
3.4.9.Counting backward through a for loop