HTML Preparation code:
AخA
 
1
<script src="https://cdn.jsdelivr.net/npm/lodash@4.17.4/lodash.min.js"></script>
Script Preparation code:
x
 
window.foo = ['cat', 'dog', 'bird'];
window.bar = ['cat', 'dog', 'bird'];
window.equals = (a, b) =>
  a.length === b.length &&
  a.every((v, i) => v === b[i]);
window.equalsIgnoreOrder = (a, b) => {
  if (a.length !== b.length) return false;
  const uniqueValues = new Set([...a, ...b]);
  for (const v of uniqueValues) {
    const aCount = a.filter(e => e === v).length;
    const bCount = b.filter(e => e === v).length;
    if (aCount !== bCount) return false;
  }
  return true;
}
Tests:
  • _.isEqual

     
    _.isEqual(window.foo, window.bar)
  • JSON.stringify

     
    JSON.stringify(window.foo) === JSON.stringify(window.bar);
  • equals

     
    window.equals(window.foo, window.bar)
  • equalsIgnoreOrder

     
    window.equalsIgnoreOrder(window.foo, window.bar)
Rendered benchmark preparation results:

Suite status: <idle, ready to run>

Previous results

Experimental features:

  • Test case name Result
    _.isEqual
    JSON.stringify
    equals
    equalsIgnoreOrder

    Fastest: N/A

    Slowest: N/A

Latest run results:
Run details: (Test run date: 2 months ago)
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/134.0.0.0 Safari/537.36 Edg/134.0.0.0
Chrome 134 on Windows
View result in a separate tab
Test name Executions per second
_.isEqual 15618695.0 Ops/sec
JSON.stringify 8565059.0 Ops/sec
equals 116523576.0 Ops/sec
equalsIgnoreOrder 7431307.0 Ops/sec