JavaScript includes() Performance

Benchmark created on


Setup

const numbers = [2, 4, 6, 8, 10];

Test runner

Ready to run.

Testing in
TestOps/sec
Without includes() method
function areAllEvenNumbers(array) {
  for (let i = 0; i < array.length; i++) {
    if (array[i] % 2 !== 0) {
      return false;
    }
  }
  
  return true;
}


const isAllEven = areAllEvenNumbers(numbers);
console.log(isAllEven);
ready
Using includes() method
const isAllEven = numbers.every(e => e % 2 === 0);
console.log(isAllEven);
ready

Revisions

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