Another way to declare the two-dimensional array : Two Dimensional Array « Data Type « JavaScript DHTML






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

1.Use nested for loop to loop through the two-dimension array
2.Sort two dimensional array
3.Use two-dimensional array to store matrix data