for in





js/script.js
  • var ara0 = [1, 2, 3, 4, 5];
  •  
  • var ara1 = new Object();
  • ara1['one'] = 1;
  • ara1['two'] = 2;
  • ara1['three'] = 3;
  • ara1['four'] = 4;
  • ara1['five'] = 5;
  •  
  • function objOne() {
  •  this.val0 = 'Hello World!',
  •  this.val1 = 'Привет Мир!',
  •  this.val2 = 'To be or not to be?'
  • }
  •  
  • function funMake() {
  •  for(var i in ara0) {
  •   document.write(i + ' ');
  •  }
  •  document.write('<br /><br />');
  •  
  •  for(var i in ara1) {
  •   document.write(i + '&nbsp;=&nbsp;' + ara1[i] + '<br />');
  •  }
  •  document.write('<br />');
  •  
  •  var O = new objOne();
  •  for(var i in O) {
  •   document.write(i + '&nbsp;=&nbsp;' + O[i] + '<br />');
  •  }
  • }
  • var ara0 = [1, 2, 3, 4, 5];
  •  
  • var ara1 = new Object();
  • ara1['one'] = 1;
  • ara1['two'] = 2;
  • ara1['three'] = 3;
  • ara1['four'] = 4;
  • ara1['five'] = 5;
  •  
  • function objOne() {
  •  this.val0 = 'Hello World!',
  •  this.val1 = 'Привет Мир!',
  •  this.val2 = 'To be or not to be?'
  • }
  •  
  • function funMake() {
  •  for(var i in ara0) {
  •   document.write(i + '&nbsp;');
  •  }
  •  document.write('<br /><br />');
  •  
  •  for(var i in ara1) {
  •   document.write(i + '&nbsp;=&nbsp;' + ara1[i] + '<br />');
  •  }
  •  document.write('<br />');
  •  
  •  var O = new objOne();
  •  for(var i in O) {
  •   document.write(i + '&nbsp;=&nbsp;' + O[i] + '<br />');
  •  }
  • }


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>