Creating arrays from 1 to n

Benchmark created on


Setup

const size = 1000000

Test runner

Ready to run.

Testing in
TestOps/sec
array keys
Array.from(Array(size).keys()).map(i => i+1)
ready
array keys 2
Array.from(Array(size).keys().map(i => i+1))
ready
array from
Array.from({length: size}, (_, i) => i + 1)
ready
array spread
[...Array(size).keys()].map(i => i+1)
ready
array spread 2
[...Array(size).keys().map(i => i+1)]
ready

Revisions

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