Array in JavaScript

 
In javaScript array is the object that is capable of storing a sequence of values. These values are stored in indexed locations within the array. Number of elements in Array is called by length of array.

An array must be declare before it is used
We can declare Array in javascript like as:

ArrayName = new array(length)
ArrayName = new Array()

In first declaration array size is explicitly specified. This array will help pre-determined set of values.
In second declaration array is the size of 0.

One is important thing is here that JavaScript automatically extends the length of any array when new array elements are initialized. For example:

Arr_City = new Array()
Arr_City[5] = “NewDelhi”
Arr_City[10] = “London”

in above example, it will extend the size of the array Arr_City to 6 and initialized Arr_City[5]. When javaScript encounters the reference to city[10] it will extend the size of the array Arr_City to 11 and initialized Arr_City[10].

2 thoughts on “Array in JavaScript”

  1. Hi,
    Array is collection of similar type of elements. We can use concept of array to make program more readable, easy to handle large data and implementing concept of loops in program. With the help of array the size of code is also decrease. When we allocate memory to objects in array then allocation of element in memory is continuous. Array is used in static data structure to represents data in memory. In this demonstration we learn how to implement array in java script……..
    for more details please check out this link…….
    http://mindstick.com/Articles/fb4fe8cd-89a5-45c1-adcb-38f0a89aad7e/?Array%20in%20java%20script
    Thanks !!!!!!
     

Comments are closed.