Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
findIndex + toSpliced vs map
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:152.0) Gecko/20100101 Firefox/152.0
Browser:
Firefox 152
Operating system:
Windows
Device Platform:
Desktop
Date tested:
27 days ago
Test name
Executions per second
findIndex + toSpliced
15149637.0 Ops/sec
map
18332364.0 Ops/sec
Script Preparation code:
var items = [{name: 'name1', value: 1},{name: 'name2', value: 1},{name: 'name3', value: 1},{name: 'name4', value: 1}]; var search = 'name4'; var result = [];
Tests:
findIndex + toSpliced
var index = items.findIndex(({name}) => name === search); if (index >= 0) { result = items.toSpliced(index, 1, {...items[index], value: 2}); }
map
result = items.map(item => item.name === search ? {...item, value: 2} : item)