Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
js array copy speed comparison and spread operator
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/145.0.0.0 Safari/537.36
Browser:
Chrome 145
Operating system:
Windows
Device Platform:
Desktop
Date tested:
one month ago
Test name
Executions per second
map
2318.5 Ops/sec
array.from
2796.1 Ops/sec
for loop
2598.4 Ops/sec
foreach
2581.9 Ops/sec
slice
2766.9 Ops/sec
spread
2779.9 Ops/sec
Tests:
map
const arr = Array.from({ length: 10_000 }, (_, i) => i) const newArr = arr.map(e=>e)
array.from
const arr = Array.from({ length: 10_000 }, (_, i) => i) const newArr = Array.from(arr)
for loop
const arr = Array.from({ length: 10_000 }, (_, i) => i) let newArr = []; for(let i = 0; i < arr.length; i++) { newArr[i] = arr[i]; }
foreach
const arr = Array.from({ length: 10_000 }, (_, i) => i) let newArr = [] arr.forEach(e => { newArr.push(e) })
slice
const arr = Array.from({ length: 10_000 }, (_, i) => i) const newArr = arr.slice()
spread
const arr = Array.from({ length: 10_000 }, (_, i) => i) const newArr = [...arr]