Home Java Javascript-array Array Empty
Questions:Ask|Latest

 
 

Share on Google+Share on Google+

Array Empty

Advertisement
In this Tutorial we want to describe you a code that makes you easy to understand in an Array Empty.

Array Empty

     

In this Tutorial we want to describe you a code that makes you easy to understand in an Array Empty. For this example we are using Java Scripting language. The code illustrate on loading a page invoke a function display ( ),this include the variable array that is used to  instantiate an array object .The if clause evaluate ,incase the length of array is less than1,then document. write print an Array is empty. An array object hold the various element accessed by indexes [0]-[5].The for loop execute and run the script till the variable i is less than the array length. Finally the document. write print the element after adding.

 

Array Empty.html

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

  <script>

  function display(){
  var array = new Array();

  if(array.length <1) {
  document.write("<b>Array is empty :</b>");
  }

  array[0"Ajay";
  array[1"Bhanu";
  array[2"Komal";
  array[3"Rakesh";
  array[4"Santosh"
  array[5"Tanuj"
  document.write("<br><br><b>After Adding ...</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

Ask Questions?    Discuss: Array Empty  

Post your Comment


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