Toggle navigation
MeasureThat
.net
Create a benchmark
Tools
Feedback
Feature Requests
FAQ
Register
Log In
Run results for:
js array copy speed comparison with spread operator
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/142.0.0.0 Safari/537.36
Browser:
Chrome 142
Operating system:
Mac OS X 10.15.7
Device Platform:
Desktop
Date tested:
10 months ago
Benchmark engine:
Benchmark.js
slice
119.1M/s
map
97.0M/s
spread
85.2M/s
array.from
75.6M/s
for loop
59.5M/s
foreach
58.3M/s
View exact numbers
Test name
Executions per second
✓
slice
119,085,120 Ops/sec
map
96,959,472 Ops/sec
spread
85,195,832 Ops/sec
array.from
75,606,400 Ops/sec
for loop
59,500,612 Ops/sec
foreach
58,335,808 Ops/sec
Tests:
map
const arr = [1,2,3,4,5] const newArr = arr.map(e=>e)
array.from
const arr = [1,2,3,4,5] const newArr = Array.from(arr)
for loop
const arr = [1,2,3,4,5] let newArr = []; for(let i = 0; i < arr.length; i++) { newArr[i] = arr[i]; }
foreach
const arr = [1,2,3,4,5] let newArr = [] arr.forEach(e => { newArr.push(e) })
slice
const arr = [1,2,3,4,5] const newArr = arr.slice()
spread
const arr = [1,2,3,4,5] const newArr = [...arr]