How to set length to this array var arr = [];

Hi guys,
I must have been asking very stupid question.
But how do you set length to this array:

var arr = [];

I want to have it like:

var arr = new Array(1024);

Thank you,

The second method is the only way to initialize an array with a specified length, but there’s no advantage to doing so, as JavaScript’s arrays expand dynamically, and it can lead to confusion as the arr.length property will no longer reflect the number of elements in the array.

2 Likes