It is used to store a set of values in single variable name. Each of value is an element of the array and contains related index number. You can refer to a specific element in the array using the name of the array & the index number. The index number begins at zero.
You develop an instance of the Array object along with the "new" keyword. var family_names=new Array(5)
The expected number of elements goes within the parentheses; in this case it is five.
You assign data to each elements in the array such as:
family_names[0]="Sharma" family_names[1]="Singh" family_names[2]="Gill"
family_names[3]="Kumar" family_names[4]="Khan"
The data can be retrieved from any of the element using the index of the array element you desire:
Mother=family_names[0] father=family_names[1]
The Most Commonly Used Array Methods
Methods
|
Explanation
|
Length
|
Returns the number of elements in an array. This property is assigned a value while an array is created
|
reverse( )
|
Returns the array reversed
|
slice( )
|
Returns a indicated part of the array
|
Sort( )
|
Returns a sorted array
|