Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
find vs findIndex vs loop for 2
(version: 1)
Measuring which is faster
Comparing performance of:
Array.prototype.find vs Array.prototype.findIndex vs for loop
Created:
one year ago
by:
Guest
Jump to the latest result
Script Preparation code:
var arr = []; var i = 0; while (i <= 1E5) arr[i] = i++;
Tests:
Array.prototype.find
const item = arr.find(item => item == 1E5);
Array.prototype.findIndex
const index = arr.findIndex(item => item == 1E5);
for loop
let index = -1; for(let i = 0; i < arr.length; i++) { if(arr[i] == 1E5) { index = i; break; } }
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (3)
Previous results
Fork
Test case name
Result
Array.prototype.find
Array.prototype.findIndex
for loop
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
9 months ago
)
User agent:
Mozilla/5.0 (Windows NT 10.0; rv:128.0) Gecko/20100101 Firefox/128.0
Browser/OS:
Firefox 128 on Windows
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
Array.prototype.find
3195.5 Ops/sec
Array.prototype.findIndex
3172.0 Ops/sec
for loop
20882.5 Ops/sec
Related benchmarks:
find vs findIndex (Array prototype methods)
find vs findIndex (Array prototype methods) 22
find vs findindex with condition test
find vs findIndex (Array prototype methods) 2
find vs findIndex (Array prototype methods) object
find vs findIndex vs for in (Array prototype methods)
find vs findIndex get item
find vs for of
find vs findIndex vs loop for
Comments
Confirm delete:
Do you really want to delete benchmark?