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))
  • reduce 2

     
    const a = [1, 2, 3, 4, 5];
    const b = [1, 2, 4, 5, 3, 5];
    a.reduce(function (x, y, i) {
      return 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
    reduce 2

    Fastest: N/A

    Slowest: N/A

Latest run results:
Run details: (Test run date: 3 years ago)
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/99.0.4844.51 Safari/537.36
Chrome 99 on Mac OS X 10.15.7
View result in a separate tab
Test name Executions per second
every 85181024.0 Ops/sec
for of loop 54940000.0 Ops/sec
for loop 32854398.0 Ops/sec
reduce 97258496.0 Ops/sec
reduce 2 97750032.0 Ops/sec