Toggle navigation
MeasureThat
.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
js array copy speed comparison - spread
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:135.0) Gecko/20100101 Firefox/135.0
Browser:
Firefox 135
Operating system:
Windows
Device Platform:
Desktop
Date tested:
one year ago
for loop
15.1M/s
foreach
13.7M/s
slice
13.5M/s
map
10.7M/s
spread
7.2M/s
array.from
4.1M/s
View exact numbers
Test name
Executions per second
✓
for loop
15,137,293 Ops/sec
foreach
13,655,042 Ops/sec
slice
13,536,197 Ops/sec
map
10,653,647 Ops/sec
spread
7,216,431 Ops/sec
array.from
4,118,789 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]