многомерный массив





js/script.js
  • //1 variant
  • var ara0 = [[],[]];
  • ara0[0][0] = 1;
  • ara0[0][1] = 2;
  • ara0[0][2] = 3;
  • ara0[1][0] = 10;
  • ara0[1][1] = 20;
  • ara0[1][2] = 30;
  •  
  • //2 variant
  • var ara1 = [[1, 2, 3], [10, 20, 30]];
  •  
  • function funMake() {
  •  for(var i=0; i<2; i++) {
  •   for(var j=0; j<3; j++) {
  •    document.write(ara0[i][j] + '&nbsp');
  •   }
  •  }
  •  document.write('<br /><br />');
  •  for(var i=0; i<2; i++) {
  •   for(var j=0; j<3; j++) {
  •    document.write(ara1[i][j] + '&nbsp');
  •   }
  •   document.write('<br />');
  •  }
  • }
//1 variant
var ara0 = [[],[]];
ara0[0][0] = 1;
ara0[0][1] = 2;
ara0[0][2] = 3;
ara0[1][0] = 10;
ara0[1][1] = 20;
ara0[1][2] = 30;

//2 variant
var ara1 = [[1, 2, 3], [10, 20, 30]];

function funMake() {
 for(var i=0; i<2; i++) {
  for(var j=0; j<3; j++) {
   document.write(ara0[i][j] + ' ');
  }
 }
 document.write('

'); for(var i=0; i<2; i++) { for(var j=0; j<3; j++) { document.write(ara1[i][j] + ' '); } document.write('
'); } }


index.html
  • <!DOCTYPE html>
  • <html>
  • <head>
  •  <meta charset="utf-8" />
  •  <title>New Page</title>
  •  <script src="js/script.js"></script>
  • </head>
  • <body>
  • <script>
  •  funMake();
  • </script>
  • </body>
  • </html>
  • <!DOCTYPE html>
  • <html>
  • <head>
  •  <meta charset="utf-8" />
  •  <title>New Page</title>
  •  <script src="js/script.js"></script>
  • </head>
  • <body>
  • <script>
  •  funMake();
  • </script>
  • </body>
  • </html>