Initializing iterable Arrays with some length

Benchmark created on


Description

Testing how fast different ways you can create a new array of length N, which you are capable of iterating over using functions like map or forEach.

Setup

const length = 10000

Test runner

Ready to run.

Testing in
TestOps/sec
Array using .from()
const arr = Array.from({ length })
ready
Array using constructor + fill
const arr = Array(length).fill()
ready
Array using constructor + spread
const arr = [...Array(length)]
ready

Revisions

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