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 (Macintosh; Intel Mac OS X 10.12; rv:109.0) Gecko/20100101 Firefox/115.0
Browser:
Firefox 115
Operating system:
Mac OS X 10.12
Device Platform:
Desktop
Date tested:
5 months ago
slice
8K/s
for loop
6K/s
map
4K/s
array.from
4K/s
spread
4K/s
foreach
4K/s
View exact numbers
Test name
Executions per second
✓
slice
8,293 Ops/sec
for loop
5,608 Ops/sec
map
4,145 Ops/sec
array.from
4,130 Ops/sec
spread
3,944 Ops/sec
foreach
3,646 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]