индексный массив





js/script.js
  • //1 variant
  • var ara0 = [];
  • ara0[0] = 1;
  • ara0[1] = 2;
  • ara0[2] = 3;
  • ara0[3] = 4;
  • ara0[4] = 5;
  •  
  • //2 variant
  • var ara1 = [1, 2, 3, 4, 5];
  •  
  • //3 variant
  • var ara2 = Array();
  • ara2[0] = 1;
  • ara2[1] = 2;
  • ara2[2] = 3;
  • ara2[3] = 4;
  • ara2[4] = 5;
  •  
  • //4 variant
  • var ara3 = Array(1, 2, 3, 4, 5);
  •  
  • var ara4 = [10, 0.2802, true, 'Hello World!', {x:300, y:'Привет Мир!'}];
  •  
  • function funMake() {
  •  for(var i=0; i<ara0.length; i++) {
  •   document.write(ara0[i] + '&nbsp');
  •  }
  •  document.write('<br />');
  •  for(var i=0; i<ara1.length; i++) {
  •   document.write(ara1[i] + '&nbsp');
  •  }
  •  document.write('<br />');
  •  for(var i=0; i<ara2.length; i++) {
  •   document.write(ara2[i] + '&nbsp');
  •  }
  •  document.write('<br />');
  •  for(var i=0; i<ara3.length; i++) {
  •   document.write(ara3[i] + '&nbsp');
  •  }
  •  document.write('<br />');
  •  document.write(ara4[0] + '<br />');
  •  document.write(ara4[1] + '<br />');
  •  document.write(ara4[2] + '<br />');
  •  document.write(ara4[3] + '<br />');
  •  document.write(ara4[4].x + '<br />');
  •  document.write(ara4[4].y + '<br />');
  • }
//1 variant
var ara0 = [];
ara0[0] = 1;
ara0[1] = 2;
ara0[2] = 3;
ara0[3] = 4;
ara0[4] = 5;

//2 variant
var ara1 = [1, 2, 3, 4, 5];

//3 variant
var ara2 = Array();
ara2[0] = 1;
ara2[1] = 2;
ara2[2] = 3;
ara2[3] = 4;
ara2[4] = 5;

//4 variant
var ara3 = Array(1, 2, 3, 4, 5);

var ara4 = [10, 0.2802, true, 'Hello World!', {x:300, y:'Привет Мир!'}];

function funMake() {
 for(var i=0; i');
 for(var i=0; i');
 for(var i=0; i');
 for(var i=0; i');
 document.write(ara4[0] + '
'); document.write(ara4[1] + '
'); document.write(ara4[2] + '
'); document.write(ara4[3] + '
'); document.write(ara4[4].x + '
'); document.write(ara4[4].y + '
'); }


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>