Tests:
  • every

    AخA
     
    const a = [1, 2, 3, 4, 5];
    const b = [1, 2, 4, 5, 3, 5];
    a.every(x => b.some(y => x === y));
  • for of loop

     
    const a = [1, 2, 3, 4, 5];
    const b = [1, 2, 4, 5, 3, 5];
    for (let x of a) {
        if (!b.some(y => x === y)) {
            break; 
        }
    }
  • for loop

     
    const a = [1, 2, 3, 4, 5];
    const b = [1, 2, 4, 5, 3, 5];
    for (let i = 0; i < a.length; i++) {
        if (!b.some(y => a[i] === y)) {
            break; 
        }
    }
  • reduce

     
    const a = [1, 2, 3, 4, 5];
    const b = [1, 2, 4, 5, 3, 5];
    a.reduce((x, y, i) => i === 0 ? b.some(p => p === x) : b.some(p => p === y))
Rendered benchmark preparation results:

Suite status: <idle, ready to run>

Previous results

Experimental features:

  • Test case name Result
    every
    for of loop
    for loop
    reduce

    Fastest: N/A

    Slowest: N/A

Latest run results:
Run details: (Test run date: 3 years ago)
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/95.0.4638.69 Safari/537.36 Edg/95.0.1020.53
Chrome 95 on Windows
View result in a separate tab
Test name Executions per second
every 112381608.0 Ops/sec
for of loop 77975248.0 Ops/sec
for loop 42828488.0 Ops/sec
reduce 120075280.0 Ops/sec