Share on Google+Share on Google+

JavaScript Array Class

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

<h2>Use of Array Class</h2>
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>");
<body bgcolor="lightBlue"/>

Output will be displayed as:

Download Source Code



Posted on: November 11, 2008 If you enjoyed this post then why not add us on Google+? Add us to your Circles

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.

Discuss: JavaScript Array Class  

Post your Comment

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