Array fill vs Array from (v9)

Revision 9 of this benchmark created on


Test runner

Ready to run.

Testing in
TestOps/sec
Array from

const A = Array.from(Array(1e5), (_, i) => i)
ready
Array from 2
const A = Array.from({ length: 1e5 }, (_, i) => i)
ready
Array from 3
const A = Array.from({ length: 1e5 })
ready
Array fill
const A = Array(1e5).fill(0).map((_, i) => i)
ready
Array fill limited
const A = Array(2).fill(0).map((_, i) => i)
ready
Array from limited

const A = Array.from(Array(2), (_, i) => i)
ready
Array from 2 limited
const A = Array.from({ length: 2 }, (_, i) => i)
ready
Array from 3 limited
const A = Array.from({ length: 2 })
ready

Revisions

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