Array equality

Benchmark created on


Preparation HTML

<script src="https://cdn.jsdelivr.net/npm/lodash@4.17.21/lodash.min.js"></script>

Setup

const LENGTH = 1000
let ARR_1 = Array(LENGTH).fill(0).map(() => Math.floor(Math.random() * LENGTH));
let ARR_2 = Array(LENGTH).fill(0).map(() => Math.floor(Math.random() * LENGTH));

const arraysEqual = (
  arr1,
  arr2,
) => {
  if (arr1.length !== arr2.length) return false;

  return arr1.every(item => arr2.includes(item));
};

Test runner

Ready to run.

Testing in
TestOps/sec
Lodash.isEqual
_.isEqual(ARR_1, ARR_2);
ready
arraysEqual
arraysEqual(ARR_1, ARR_2)
ready

Revisions

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