Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
findIndex vs map with indexOf
(version: 0)
Comparing performance of:
Array index of vs Map index of
Created:
2 years ago
by:
Guest
Jump to the latest result
Script Preparation code:
var array = []; for (var i = 0; i < 300; ++i) { array.push({ 'id': i, 'name': 'test-' + i }); } function hasWithIndexOf(id) { return array.findIndex(i => i.id === id); } var map = array.map(i => i.id); function hasWithMap(id) { return map.indexOf(id); }
Tests:
Array index of
for (var i=0; i<100; ++i) { hasWithIndexOf('404'); }
Map index of
for (var i=0; i<100; ++i) { hasWithMap('404'); }
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (2)
Previous results
Fork
Test case name
Result
Array index of
Map index of
Fastest:
N/A
Slowest:
N/A
Latest run results:
No previous run results
This benchmark does not have any results yet. Be the first one
to run it!
Related benchmarks:
index vs lastindexofasdf
Array find with indexOf vs includes
indexOf vs map with indexOf
findIndex vs indexOf - JavaScript performance v2
Comments
Confirm delete:
Do you really want to delete benchmark?