Toggle navigation
MeasureThat
.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
array indexOf vs includes vs some
(version: 1)
performance comparison of ways to find if an array contains a value
Comparing performance of:
IndexOf vs Includes vs some
Created:
one year ago
by:
Guest
Go to the latest result
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']
Tests:
IndexOf
array.indexOf('sausage') > -1
Includes
array.includes('sausage')
some
array.some(v => v === 'sausage')
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (3)
Previous results
Fork
Test case name
Result
IndexOf
Includes
some
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
5 months ago
)
User agent:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/145.0.0.0 Safari/537.36 Edg/145.0.0.0
Browser/OS:
Chrome 145 on Windows
View result in a separate tab
Embed
Embed Benchmark Result
some
125.2M/s
IndexOf
115.2M/s
Includes
114.3M/s
View exact numbers
Test name
Executions per second
✓
some
125,238,160 Ops/sec
IndexOf
115,225,000 Ops/sec
Includes
114,261,152 Ops/sec
Related benchmarks
array indexOf vs includes vs some
map includes vs some
array.indexOf vs array.includes vs array.some vs equality
array indexOf vs includes vs some vs for loop
Comments
Confirm delete:
Do you really want to delete benchmark?