Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
findIndex vs indexOf vs object property
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (X11; Linux x86_64; rv:146.0) Gecko/20100101 Firefox/146.0
Browser:
Firefox 146
Operating system:
Linux
Device Platform:
Desktop
Date tested:
6 months ago
Test name
Executions per second
indexOf
16821.9 Ops/sec
findIndex
6649.0 Ops/sec
object property
765432832.0 Ops/sec
Script Preparation code:
var arr = new Array(15000); arr.fill('') arr = arr.map(el => Math.random().toString(36).replace(/[^a-z]+/g, '').substr(0, 8)); var foo = 'erjhfdjh'; arr[7500]=foo; var obj = arr.reduce((acc,key,i)=>{acc[key]=i;return acc},{});
Tests:
indexOf
var index = arr.indexOf(foo);
findIndex
var index = arr.findIndex(o => o===foo);
object property
var index = obj[foo]