Script Preparation code:
AخA
 
const arr = Array.from({ length: 20000 }, (_, i) => ({ property: i }))
const elementToFind = 15000;
Tests:
  • Array.find

    x
     
    const arr = Array.from({ length: 20000 }, (_, i) => ({ property: i }))
    const elementToFind = 15000;
    const element = arr.find((el) => el.property === elementToFind);
  • For-loop

     
    const arr = Array.from({ length: 20000 }, (_, i) => ({ property: i }))
    const elementToFind = 15000;
    let element = undefined;
    for (let i = 0; i < arr.length; i++) {
        if (arr[i].property === elementToFind) {
          element = arr[i];
          break;
        }
    }
Rendered benchmark preparation results:

Suite status: <idle, ready to run>

Previous results

Experimental features:

  • Test case name Result
    Array.find
    For-loop

    Fastest: N/A

    Slowest: N/A

Latest run results:
Run details: (Test run date: yesterday)
Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:138.0) Gecko/20100101 Firefox/138.0
Firefox 138 on Mac OS X 10.15
View result in a separate tab
Test name Executions per second
Array.find 5582.0 Ops/sec
For-loop 7212.7 Ops/sec