How can I define an array in JavaScript?
Answer Posted / madhav arora
Arrays can be defined in following three ways :
1. regular method:
ex: var arrayname=new Array();
arrayname[0]="abc";
arrayname[1]="pqr";
arrayname[2]="xyz";
2.condensed method:
ex: var arrayname=new Array("abc","pqr","xyz");
3.literal method:
ex:var arrayname=["abc","pqr","xyz"];
Is This Answer Correct ? | 16 Yes | 4 No |
Post New Answer View All Answers
What is stack in javascript?
Create an array in javascript with a list of 4 colors, assign that array to the variable, ‘colors’.
Where can I learn javascript for free?
How to create a confirmation box?
Name some of the ways in which Type Conversion is possible?
Can you explain about screen object?
Taking a developer's perspective, do you think that that javascript is easy to learn and use?
Write the code for adding new elements dynamically?
What and where are the best javascript resources on the web?
What is a global variable in programming?
Explain why "self" is needed instead of "this".
How can you create an Object in JavaScript?
What is difference between api and library?
Name some of the built-in methods and the values returned by them.
How do I use an external javascript file?