Use nested for loop to loop through the two-dimension array
<html>
<head>
<title>Array literal</title>
<script type="text/javascript" >
var planets = new Array(
new Array('A', 'B', 'C'),
new Array('D', 'E', 'F')
);
for (var i = 0; i < planets.length; i++)
{
for (var j = 0; j < planets[i].length; j++)
{
document.write('planets[' + i + '][' + j + '] = ' + planets[i][j]);
document.write('<BR>');
}
}
</script>
</head>
<body>
</body>
</html>
Related examples in the same category