Consider these 2 examples:
const length = 1000;
const array = [];
for (let i = 0; i < length; ++i) {
array.push(true);
}
and
const length = 1000;
const array = new Array(length);
for (let i = 0; i < length; ++i) {
array[i] = true;
}
They produce the same result (creating and filling an array), but in the second case the code tells the JS engine the expected array length.
Does it make sense to make a more complex code like in the second example? Does it give any advantages (e.g. performance improvements)?