| Viewed 387 times

How to declare array in javascript


How to declare array in javascript

1 Answer
Mohammad Qandeel
Answered
5

to declare an array in javascript you can use the javascript Keyword new

Example

var numbers= new Array(1,2,3,4,5);

or 

var numbers = [1,2,3,4,5];

and you can access the Elements of an array by index 

console.log(numbers[0]); //1
console.log(numbers[1]); //2

 



Related Questions