Run details:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.90 Safari/537.36
Chrome 89
Mac OS X 10.14.6
Desktop
3 years ago
Test name Executions per second
_.isEqual 1454304.2 Ops/sec
Native 65404.5 Ops/sec
HTML Preparation code:
AخA
 
1
<script src='https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.17.5/lodash.min.js'></script>
Script Preparation code:
 
window.foo = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'];
window.bar = ['a', 'c', 'b', 'd', 'e', 'f', 'g', 'h', 'j', 'i', 'k', 'l', 'm', 'n', 'p', 'o', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'];
Tests:
  • _.isEqual

     
    _.isEqual(window.foo, window.bar)
  • Native

     
    if (window.foo.length !== window.bar.length) return false;
      const uniqueValues = new Set([...window.foo, ...window.bar]);
      for (const v of uniqueValues) {
        const fooCount = window.foo.filter(e => e === v).length;
        const barCount = window.bar.filter(e => e === v).length;
        if (fooCount !== barCount) return false;
      }
      return true;