Vaibhav
Vaibhav

Reputation: 105

creating new array in jQuery with specified length

How can I create a blank array of length 4 in jQuery. I want to create the array first and later want to punch values in it.

Upvotes: 1

Views: 2232

Answers (1)

Tushar
Tushar

Reputation: 87203

Use Array Constructor, new Array(arrayLength)

var array = new Array(4);

Note: This array is not essentially blank, it contains undefined but it's length is 4.

If feasible,

var arr = [1, 2, 3, 4];

Upvotes: 3

Related Questions