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

Revision 5 of this 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
Array().fill()
const array = Array.from(Array(size), (_, index) => index)
ready
for loop 2
const array = Array(size);

for (let i = 0; i < size; i++) {
    array[i] = i;
}
ready

Revisions

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