Append elements to Array by using the index : Array Index « Array « JavaScript Tutorial






<html>
<head>
<title>Append elements to Array by using the index</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>








11.3.Array Index
11.3.1.Reference array value by index
11.3.2.Use variable as the array index
11.3.3.Append elements to Array by using the index
11.3.4.Use for each loop to assign array element value
11.3.5.Reference array element by random index value