Array for vs fill (v2)

Revision 2 of this benchmark created on


Test runner

Ready to run.

Testing in
TestOps/sec
Array fill
const result = Array(1e7).fill(undefined)
ready
Array for
const result = Array(1e7)
for( var i = 0; i < result.length; i++) {
   result[i] = undefined;
}
ready
Array map
const result = Array(1e7)

const empty = result.map(() => undefined);
ready
Array from
const result = Array.from({length: 1e7}, () => undefined);
ready

Revisions

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