Home Java Javascript-array JavaScript array first element



JavaScript array first element
Posted on: November 11, 2008 at 12:00 AM
In this Tutorial we want to describe you a code that makes you easy to understand in array first element example.

JavaScript array first element

     

In this Tutorial we want to describe you a code that makes you easy to understand in array first element example. For this we are using Java Scripting language This code show a page on loading invokes a function display. This function  include a variable array that is used to instantiate an array object. The array object hold the various element .The for loop executes and run the script till the variable i is less than 3.The document. write print the element from  array index[0]-[3].The document. write[array(0)] print the 1st element hold by an array object in index[0] i.e Komal.

First Element.java


<html>
  <head>
  <tit le>First Element</title>
  
  <script>

  function display() {
  
  var array = new Array(3);
  array[0"Komal";
  array[1"Rakesh";
  array[2"Santosh"
  
  document.write("<b>Array is :</b><br>");
  for(i = 0; i < 3; i++) {
  document.write(array[i]+"<br>");
  }
  document.write("<br><b>1st Element of the array :</b><br>");
  document.write(array[0]);
  
  }
  </script>
  </head>
  
  <body onload="display();">
  
  </body>
</html>

Output


Download code

Related Tags for JavaScript array first element:
javacarrayscriptingantfunctionscriptlanguagefuniomakeloaddisplayippagetutorialusingriathisloadingelementinvokeshowforexampleunctoexamlanshedessplfirstinasstamntplaywanjispadesemfuncagemehowdescribetorxaxampsspatkisirhamplrayeaandarcodcodewantvatutorscrssriripthshoavsthatdisppleplndodeono


More Tutorials from this section

Ask Questions?    Discuss: JavaScript array first element  

Post your Comment


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

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.