Define two arrays and use for statement to ouput their values : Array Declaration « Array « JavaScript Tutorial






<html>
<head>
<title>Define two arrays and use for statement to ouput their values</title>

</head>
<body>

<h1>Define two arrays and use for statement to ouput their values</h1>

<table border="1">

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

var myArray    = new Array();
    myArray[0] = "A";
    myArray[1] = "B";
    myArray[2] = "C";
    myArray[3] = "D";
    myArray[4] = "E";

var myArray2    = new Array();
    myArray2[0] = "1";
    myArray2[1] = "2";
    myArray2[2] = "3";
    myArray2[3] = "4";
    myArray2[4] = "5";

for (var i=0; i<myArray.length; i++) {
  document.write("<tr><td>" + myArray[i] + "</td>");
  document.write("<td>" + myArray2[i] + "</td></tr>");
}

//-->
</script>

</table>

</body>
</html>








11.2.Array Declaration
11.2.1.Array declaration with element count
11.2.2.Integer Array Declaration with initialization
11.2.3.Initialize a string array during declaration and check the array size
11.2.4.Define two arrays and use for statement to ouput their values
11.2.5.Store strings in array
11.2.6.Output array element in a HTML table format
11.2.7.Paralled array