Array creation with for loop vs. Array().map()

Benchmark created on


Setup

const size = 100_000;

Test runner

Ready to run.

Testing in
TestOps/sec
for loop
const array = [];

for (let i = 0; i < size; i++) {
    array.push(i);
}
ready
Array().map()
const array = Array(size).map((entry, index) => index);
ready

Revisions

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