How to create arrays in JavaScript?

Answer

here are two ways to create array in JavaScript like other languages:

a) The first way to create array
Declare Array:

Code
var names = new Array(); 
Add Elements in Array:-
names[0] = "Vikas";
names[1] = "Ashish";
names[2] = "Nikhil";

b) This is the second way:

var names = new Array("Vikas", "Ashish", "Nikhil");

All javascript Questions

Ask your interview questions on javascript

Write Your comment or Questions if you want the answers on javascript from javascript Experts
Name* :
Email Id* :
Mob no* :
Question
Or
Comment* :
 





Disclimer: PCDS.CO.IN not responsible for any content, information, data or any feature of website. If you are using this website then its your own responsibility to understand the content of the website

--------- Tutorials ---