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 differential inheritance?
What does e mean in a function?
What are the different functional component in javascript?
How to count the number of element in an array using javascript?
Difference between Client side JavaScript and Server side JavaScript?
Can I learn javascript without html?
What is a nan value?
What web sites do you feel use javascript most effectively (i.e., Best-in-class examples)? The worst?
Explain javascript debounce function?
What are local variables in javascript?
Name the two functions that are used to create an HTML element dynamically?
Which built-in method sorts the elements of an array?
Which built-in method reverses the order of the elements of an array?
How to access an external javascript file that is stored externally and not embedded?
In a java script, what is the difference between "==" and "===" operator?