Toggle navigation
MeasureThat
.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
js array copy speed comparison
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (X11; Linux x86_64; rv:109.0) Gecko/20100101 Firefox/115.0
Browser:
Firefox 115
Operating system:
Linux
Device Platform:
Desktop
Date tested:
9 months ago
slice
14.8M/s
foreach
14.3M/s
for loop
13.2M/s
map
12.8M/s
array.from
5.5M/s
View exact numbers
Test name
Executions per second
✓
slice
14,801,551 Ops/sec
foreach
14,281,313 Ops/sec
for loop
13,241,525 Ops/sec
map
12,768,254 Ops/sec
array.from
5,497,972 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()