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



Home Java Javascript-array Array Declaration

Related Tutorials


 
 

Share on Google+Share on Google+

Array Declaration

Advertisement
In this Tutorial we want to describe you a code that helps you in Understanding Array Declaration.

Array Declaration

     

In this Tutorial we want to describe you a code that helps you in Understanding Array Declaration. For this we are using JavaScript as scripting language.On loading the page, the function display ( ) is invoked that include variable array, that is used to instantiate an array object. This array object hold the element specified by an array index from [0]-[3].The for loop return true and execute the script till the length of variable i is less than the array.length.Finally the document. write print the list of element that an array object hold.

Array Declaration.html


<html>
  <head>
  <title>Array Declaration</title>
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
  <style>

  </style>
  <script>
  
  function display(){
  var array = new Array();
  array[0"Ajay";
  array[1"Bhanu";
  array[2"Komal";
  array[3"Rakesh";
  array[4"Santosh"
  array[5"Tanuj"
  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

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 Declaration  

Post your Comment


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