Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
findIndex vs find vs map and indexOf - JavaScript performance
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/121.0.0.0 Safari/537.36 Edg/121.0.0.0
Browser:
Chrome 121
Operating system:
Windows
Device Platform:
Desktop
Date tested:
2 years ago
Test name
Executions per second
findIndex
24963.8 Ops/sec
find
26384.7 Ops/sec
map and indexOf
274176.4 Ops/sec
Script Preparation code:
var arr = Array.from({ length: 1000 }, (_, i) => { return { id: i, }; }); var foo = Math.floor(Math.random() * 1000);
Tests:
findIndex
const index = arr.findIndex((num) => num.id === foo);
find
const value = arr.find((num) => num.id === foo);
map and indexOf
const index = arr.map((num) => num.id).indexOf(foo);