Toggle navigation
MeasureThat
.net
Create a benchmark
Tools
Feedback
Feature Requests
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
Benchmark engine:
Benchmark.js
map and indexOf
274K/s
find
26K/s
findIndex
25K/s
View exact numbers
Test name
Executions per second
✓
map and indexOf
274,176 Ops/sec
find
26,385 Ops/sec
findIndex
24,964 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);