PDA

View Full Version : How to create arrays in javaScripts?



dennis123
05-16-2017, 02:16 AM
How to create arrays in javaScripts?

Alicelyttleton
05-16-2017, 04:05 AM
There are two syntaxes for creating an empty array: let arr = new Array(); let arr = [];. Almost all the time, the second syntax is used.

arianagrand
06-06-2017, 05:39 AM
An array where the length is greater than the amount of numbered properties is known as a sparse array while one with the length equal to the number of numbered properties is a dense array.

//Creates an array with no numbered entries

var arr = new Array(5);
test(arr);
// length: 5

var arr = [];
arr.length = 5;
test(arr);
// length: 5