Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
map vs findIndex to update unknown array index
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/125.0.0.0 Mobile Safari/537.36
Browser:
Chrome Mobile 125
Operating system:
Android
Device Platform:
Mobile
Date tested:
one year ago
Test name
Executions per second
map to create new array
18997.2 Ops/sec
findIndex to create new array
53142.3 Ops/sec
Script Preparation code:
var arr = new Array(15000); var r = Math.floor(Math.random() * 15000) arr = arr.map((e, i) => { return { id: i } })
Tests:
map to create new array
arr.map(e => e && e.id === r ? {...e, targetted: true} : e)
findIndex to create new array
var idx = arr.findIndex(e => e&& e.id === r); arr[idx] = {...arr[idx], targetted: true}