Use nested for loop to loop through the two-dimension array : Two Dimensional Array « Data Type « JavaScript DHTML






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

1.Another way to declare the two-dimensional array
2.Sort two dimensional array
3.Use two-dimensional array to store matrix data