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



Home Java Javascript-array JavaScript Array Class

Related Tutorials


 
 

Share on Google+Share on Google+

JavaScript Array Class

Advertisement
In this section, you will study how to use Array class in JavaScript.

JavaScript Array Class

     

In this section, you will study how to use Array class in JavaScript. 

The Array class is one of the predefined classes available in JavaScript from which the object is to be derived. You can see in the given example where we have created an Array object. Syntax of creating an array object is ..

var colors = new array();

Then you can add the elements into it either by passing the string to the Array or by assigning  index number. While working  with an array, you'll find that it dynamically grows in size with each additional item. You can determine the size of Array by using length property.

Here is the codes

<html>
<head>
<h2>Use of Array Class</h2>
<script>
var colors = new Array();
colors[0] = "Red";
colors[1] = "Green";
colors[2] = "Blue";
colors[3] = "White";
colors[4] = "Black";
document.write("<b>The array is= </b>");
for(i=0;i<colors.length;i++)
document.write(colors[i]+",");
</script>
<body bgcolor="lightBlue"/>
</html>

Output will be displayed as:

Download Source 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: JavaScript Array Class  

Post your Comment


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