Checking matches

Benchmark created on


Setup

const arr1 = [4,13,25,38,45,53]
const arr2 = [4,15,28,38,45,55]

Test runner

Ready to run.

Testing in
TestOps/sec
filter
const matches = arr1.filter((ball) =>arr2.includes(ball)).length
ready
For loop
  let matches = 0
  for (let i = 0; i < arr1.length; i++) {
    if (arr2.includes(arr1[i])) {
      matches++
    }
  }
ready
For loop without includes
  let matches = 0
  for (let i = 0; i < arr1.length; i++) {
    for (let j = 0; j < arr2.length; j++) {
      if (arr1[i] === arr2[j]) {
        matches++
      }
    }
  }
ready

Revisions

You can edit these tests or add more tests to this page by appending /edit to the URL.