Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
foreach vs map by wayne
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (X11; Linux x86_64; rv:133.0) Gecko/20100101 Firefox/133.0
Browser:
Firefox 133
Operating system:
Linux
Device Platform:
Desktop
Date tested:
one year ago
Test name
Executions per second
foreach
5253.7 Ops/sec
map
4218.8 Ops/sec
Tests:
foreach
let arr = Array(10000); arr.fill({name: 'ddd', age: 123}); const newArr1 = [] const newArr2 = [] arr.forEach((v) => { newArr1.push(v.name) newArr2.push(v.age) })
map
let arr = Array(10000); arr.fill({name: 'ddd', age: 123}); const newArr2 = [] const newArr1 = arr.map((v) => { newArr2.push(v.age) return v.name })