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

Revision 3 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

Revisions

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