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
We declare array and assign in next statement.
var myArray = new Array(5)
Now in order to assign elements to Array
Here length of the array is 5.
Here declaration and assignment can be done in a single statement
var myArray=new Array("Hima", "Sandhya", "Sujatha")
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