Another way to declare the two-dimensional array
<html>
<head>
<title>Array literal</title>
<script type="text/javascript" >
var planets = [
['A', 'B', 'C'],
['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