Script Preparation code:
x
 
const arr = [];
for (let i = 0; i < 10000; i++) {
    const n = 10 * Math.random();
    arr.push(Math.floor(n));
}
const set = new Set(arr);
const arr2 = [];
for (let i = 1; i <= 100; i++) arr2.push(i);
Tests:
  • array find

     
    const testArr = arr2.filter(el => arr.find(e => e === 5));
  • new Set has

     
    const testSet = arr2.filter(el => set.has(5));
Rendered benchmark preparation results:

Suite status: <idle, ready to run>

Previous results

Experimental features:

  • Test case name Result
    array find
    new Set has

    Fastest: N/A

    Slowest: N/A

Latest run results:
Run details: (Test run date: 11 days ago)
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/134.0.0.0 Safari/537.36
Chrome 134 on Windows
View result in a separate tab
Test name Executions per second
array find 406889.0 Ops/sec
new Set has 181519.1 Ops/sec