How to create an array in JavaScript?

Solution

You can create Array in JavaScript using new keyword or using array literals as shown below:-

var array1 = ["JavaScript", "Angular JS", "jQuery"];
var array2 = ["JavaScript", true, 1];
var array3 = new Array("JavaScript", "Angular JS", "jQuery"); //array3 contains 3 elements
var array4 = new Array(100)  //an empty array of length 100

Share this thread

Comments

Comments
comments powered by Disqus

Navigation

Social Media