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 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36
Browser:
Chrome 131
Operating system:
Mac OS X 10.15.7
Device Platform:
Desktop
Date tested:
one year ago
Test name
Executions per second
map to create new array
47202.3 Ops/sec
findIndex to create new array
39673.1 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}