[] vs. new Array(length)

Benchmark created on


Setup

const arr = new Array(100).fill(null).map((_, index) => index);

Test runner

Ready to run.

Testing in
TestOps/sec
[]
const target = [];

for (let i = 0; i < arr.length; i++) {
	target[i] = arr[i];
}
ready
new Array(length)
const target = new Array(arr.length);

for (let i = 0; i < arr.length; i++) {
	target[i] = arr[i];
}
ready

Revisions

You can edit these tests or add more tests to this page by appending /edit to the URL.