Array Definition

This Tutorial illustrates an code example that makes you easy to understand the code in Array Definition. On loading a page, display ( ) function is invoked.

Array Definition

     

This Tutorial illustrates an code example that makes you easy to understand the code in Array Definition. On loading a page, display ( ) function is invoked. The function display ( ) includes an array variable, used to instantiate an array object. An array object hold the list of different element varying from [0]-[5].The document. write print the Element of the array are followed by line breaker. The for loop executes the script till the length i is less than array length. Finally the document. write print the name of element that an array object hold.

 

 

 

 

Array Definition.html


<html>
  <head>
  <title>Array Definition</title>
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  <script>
  function display(){
  var array = new Array();
  array[0"One";
  array[1"Two";
  array[2"Three";
  array[3"Four";
  array[4"Five"
  array[5"Six"
  document.write("<b>Element of the array are</b><br>");
  document.write("____________________<br>");
  
  for(i=0;i<array.length;i++){
  document.write("Element "+i+" : "+array[i]+"<br>");
  }
  }
  </script>
  </head>
  <body onload="display();">
  </body>
</html>

Output
 

Download code

Advertisements

Share on Google+Share on Google+

Array Definition

Posted on: November 11, 2008 If you enjoyed this post then why not add us on Google+? Add us to your Circles

Advertisements

 

Discuss: Array Definition  

Post your Comment


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 
Comments:0

Ads

 

Ads