Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Java Javascript-array Array Definition

Related Tutorials


 
 

Share on Google+Share on Google+

Array Definition

Advertisement
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

Advertisement

If you enjoyed this post then why not add us on Google+? Add us to your Circles



Liked it!  Share this Tutorial


Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: November 11, 2008

Related Tutorials

Discuss: Array Definition  

Post your Comment


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