Test name | Executions per second |
---|---|
_.isEqual | 1454304.2 Ops/sec |
Native | 65404.5 Ops/sec |
<script src='https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.17.5/lodash.min.js'></script>
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'];
_.isEqual(window.foo, window.bar)
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;