Toggle navigation
MeasureThat
.net
Create a benchmark
Tools
Feedback
Feature Requests
FAQ
Register
Log In
Run results for:
array indexOf vs includes vs some - 100 numbers, find middle
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 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36
Browser:
Chrome 119
Operating system:
Linux
Device Platform:
Desktop
Date tested:
2 years ago
Benchmark engine:
Benchmark.js
Includes
15.9M/s
IndexOf
6.2M/s
some
5.4M/s
View exact numbers
Test name
Executions per second
✓
Includes
15,875,565 Ops/sec
IndexOf
6,207,724 Ops/sec
some
5,387,938 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 = Array(100).map((el, idx) => idx.toString());
Tests:
IndexOf
array.indexOf('50') !== 1
Includes
array.includes('50')
some
array.some(v => v === '50')