Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
Comparisons of performance for finding a value in an array
Comparing several different methods for finding an item in an array (assuming complex objects)
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/129.0.0.0 Safari/537.36
Browser:
Chrome 129
Operating system:
Windows
Device Platform:
Desktop
Date tested:
one year ago
Test name
Executions per second
Array.Prototype.find
255.1 Ops/sec
Array.Prototype.findIndex
248.1 Ops/sec
For loop
86.8 Ops/sec
LoDash
263.1 Ops/sec
Underscore
240.5 Ops/sec
HTML Preparation code:
<script src='https://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.8.3/underscore-min.js'></script> <script src='https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.17.5/lodash.min.js'></script>
Script Preparation code:
var lodash = _.noConflict(); var underscore = _.noConflict(); var array = [...Array(100000).keys()]; var key = 90000;
Tests:
Array.Prototype.find
const value = array.find(x => x === key);
Array.Prototype.findIndex
const idx = array.findIndex(x => x === key); const value = array[idx]
For loop
let value; for (let i = 0; i < array.length; i++) { if (array[i] === key) { value = array[i]; break; } }
LoDash
const value = lodash.find(array, x => x === key);
Underscore
const value = underscore.find(array, x => x === key);