C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Reviews   Communities   Interview   Jobs   Projects   Training   Your Ad Here    
Silverlight Games | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Polls | Revenue Sharing | Lobby | Gift Shop |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...







Array object



This article explains JavaScript Array object




Array


In simple words Array is collection of similar datatypes. Array index starts from 0.
Instead of declaring many variables for different strings or other data types, we can store it as a collection in an Array.

Defining an Array



Regular array


We declare array and assign in next statement.
var myArray = new Array(5)
Now in order to assign elements to Array

myArray[0]=”Hima”
myArray[1]=”Sandhya”
myArray[2]=”Sujatha”

Here length of the array is 5.

Condensed array


Here declaration and assignment can be done in a single statement

var myArray=new Array("Hima", "Sandhya", "Sujatha")

Literal array


Here we don’t use new key word to create an array. Directly we declare and assign. This is one type of declaring and assigning.

var myArray=["Hima", "Sandhya", "Sujatha"]

Index for Hima would be 0, String Sandhya is stored in 1st index and Sujatha is stored in 2nd position .

Now we can refer the element Sujatha as myArray[3]


  • Next Chapter: Array Object methods

  • Previous Chapter: JavaScript Date object's getYear()

  • Tutorial Index



  • dotNet Slackers

    About Us    Contact Us    Privacy Policy    Terms Of Use