Script Preparation code:
AخA
 
var arr = [...new Array(15000)].map((el, idx) => ({
    id: idx
}));
Tests:
  • findIndex

     
    const foo = Math.floor(Math.random() * 15000);
    arr.findIndex((itm) => itm.id === foo);
  • for loop

     
    const foo = Math.floor(Math.random() * 15000);
    for (let i = 0, j = arr.length; i < j; ++i) {
      if (arr[i].id === foo) break;
    }
Rendered benchmark preparation results:

Suite status: <idle, ready to run>

Previous results

Experimental features:

  • Test case name Result
    findIndex
    for loop

    Fastest: N/A

    Slowest: N/A

Latest run results:
Run details: (Test run date: 2 years ago)
Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/103.0.0.0 Safari/537.36
Chrome 103 on Linux
View result in a separate tab
Test name Executions per second
findIndex 120265.6 Ops/sec
for loop 2929.1 Ops/sec