Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
indexOf vs map with indexOf
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/130.0.0.0 Safari/537.36
Browser:
Chrome 130
Operating system:
Android
Device Platform:
Desktop
Date tested:
one year ago
Test name
Executions per second
Array index of
198392.7 Ops/sec
Map index of
62270.9 Ops/sec
Script Preparation code:
var array = []; for (var i = 0; i < 300; ++i) { array.push({ 'id': i, 'name': 'test-' + i }); } function hasWithIndexOf(id) { return array.indexOf(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'); }