Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
array indexOf vs includes vs some vs for loop
performance comparison of ways to find if an array contains a value
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (Android 13; Mobile; rv:147.0) Gecko/147.0 Firefox/147.0
Browser:
Firefox Mobile 147
Operating system:
Android
Device Platform:
Mobile
Date tested:
2 months ago
Test name
Executions per second
IndexOf
24478498.0 Ops/sec
Includes
24066540.0 Ops/sec
some
217715680.0 Ops/sec
for loop
206684896.0 Ops/sec
HTML Preparation code:
<script src='https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.17.5/lodash.min.js'></script>
Script Preparation code:
var array = ['banana', 'sausage', 'jesus', 'foo', 'bar', 'baz'] var len = array.length
Tests:
IndexOf
array.indexOf('sausage') !== 1
Includes
array.includes('sausage')
some
array.some(v => v === 'sausage')
for loop
for (let i = 0; i < len; i++) { if (array[i] === 'sausage') break; }