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:
5 months ago
some
217.7M/s
for loop
206.7M/s
IndexOf
24.5M/s
Includes
24.1M/s
View exact numbers
Test name
Executions per second
✓
some
217,715,680 Ops/sec
for loop
206,684,896 Ops/sec
IndexOf
24,478,498 Ops/sec
Includes
24,066,540 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; }