There are three ways to declare arrays JavaScript:
1) First way of declaration of arrays JavaScript:
var friendsName=new Array();
friendsName[0]=”John”;
friendsName[1]=”Sachin”;
friendsName[2]=”Naren”;
2) Second way of declaration of arrays JavaScript:
var friendsName =new Array(“John”,”Sachin”,”Naren”);
3) Third way of declaration of arrays JavaScript:
var friendsName =[“John”,”Sachin”,”Naren”];
Access Arrays in JavaScript is as bellow:
var firstFrndName= friendsName[0]; //we get output as John