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


Please Help Members By Posting Answers For Below Questions

what is flux in javascript?

753


What is the scope variable in javascript?

707


How can we detect os of the client machine using javascript?

697


If 2 methods have same name and same number of parameters, which one will be executed first?

698


How to select an element by id and swapping an image?

639


How do browsers work?

675


How many data types are there in javascript?

672


What javascript means?

651


What is escape() function?

693


Is javascript backend or frontend?

624


What is the reason for wrapping the entire content of a javascript source file in a function book?

758


What is the Infinity property used for in Javascript?

739


what is a difference of subclass and main class

1381


What is null javascript?

635


What is the importance of javascript? Expalin

692