How to create arrays in javaScripts?
How to create arrays in javaScripts?
There are two syntaxes for creating an empty array: let arr = new Array(); let arr = [];. Almost all the time, the second syntax is used.
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
|
Bookmarks