Home Java Javascript-array JavaScript array method



JavaScript array method
Posted on: November 10, 2008 at 12:00 AM
In This Tutorial we want to describe you a code that help you in understanding JavaScript Method For this method we have JavaScript as script language.

JavaScript array method

     

In This Tutorial we want to describe you a code that help you in understanding JavaScript Method For this method we have JavaScript as script language. We instantiate an array instance and assign to variable array. Each  component in an array is accessed by an array expression that consists of an expression whose value is an array reference indicated by subscripts indexing expression enclosed by []. The document. write print the element in an array followed by splitter line. The for loop run the scripts till the array variable is less than array length. Finally the document. write print the length of an array element by calling array. length( ) method.

 

 

 

 

ArrayLength.html

  <html>
<head>
<title>Javascript array method</title>
</head>
<body>

<script language="javascript" type="text/javascript">
var array = new Array();
array[0"Girish";
array[1"komal";
array[2"Mahendra";
document.write("<b>"+"Element in the array are "+"</b>""<br />");
document.write("=================""<br />");
for (var i=0; i<array.length; i++) {
  document.write("Element " +i+ " contains: " +array[i]"<br />");
}
document.write("=================""<br />");
document.write("<b>"+"Length of the array is: "+"</b>"+array.length);
</script>

</body>

</html>

Output of the program

Download Source code

Related Tags for JavaScript array method:
javajavascriptccomarrayantindexingscriptreferencelanguageiohelpmethodvariablesedipexpressiontutorialcomponentvalueinstanceriathisscriptsnsiscloseforindextoexpresseachssereflanssiesigndesvarceinsubasstamntwanosclosedcaosjclesstsagemecatdescribetorreferssusubscriptessatisinstantinstantiatehapressprerayeaandarcodcodeclosccconsxpunderstandingwantvatutorxiscrssririprenthsubsavstaccessabablantialuhatexifeindicicaicaptsprndodeonomo


More Tutorials from this section

Ask Questions?    Discuss: JavaScript array method  

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.