arr copy

Benchmark created on


Setup

const arr = ["A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", ]

Test runner

Ready to run.

Testing in
TestOps/sec
spread
const newArr = [...arr]
ready
for loop push
const newArr = []

for(let i = 0; i < arr.length; i++) {
	newArr.push(arr[i])
}
ready
for loop fixed arr
const newArr = new Array(arr.length)

for(let i = 0; i < newArr.length; i++) {
	newArr[i] = arr[i]
}
ready

Revisions

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