Run details:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.28 Safari/537.36
Chrome 72
Mac OS X 10.13.6
Desktop
6 years ago
Test name Executions per second
_.isEqual Level 1 627929.4 Ops/sec
JSON.stringify Level 1 380049.3 Ops/sec
_.isEqual Level 2 386601.5 Ops/sec
JSON.stringify Level 2 380078.6 Ops/sec
_.isEqual Level 3 278926.1 Ops/sec
JSON.stringify Level 3 386290.9 Ops/sec
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
 
// 1 level deep
window.foo1 = { a: 1, b: 2, c: { a: 1, b: 2, c: { a: 1, b: 2 } } };
window.bar1 = { a: 1, b: 3, c: { a: 1, b: 2, c: { a: 1, b: 2 } } };
// 2 levels deep
window.foo2 = { a: 1, b: 2, c: { a: 1, b: 2, c: { a: 1, b: 2 } } };
window.bar2 = { a: 1, b: 2, c: { a: 1, b: 3, c: { a: 1, b: 2 } } };
// 3 levels deep
window.foo3 = { a: 1, b: 2, c: { a: 1, b: 2, c: { a: 1, b: 2 } } };
window.bar3 = { a: 1, b: 2, c: { a: 1, b: 2, c: { a: 1, b: 4 } } };
Tests:
  • _.isEqual Level 1

     
    _.isEqual(window.foo1, window.bar1)
  • JSON.stringify Level 1

     
    JSON.stringify(window.foo1) === JSON.stringify(window.bar1);
  • _.isEqual Level 2

     
    _.isEqual(window.foo2, window.bar2)
  • JSON.stringify Level 2

     
    JSON.stringify(window.foo2) === JSON.stringify(window.bar2);
  • _.isEqual Level 3

     
    _.isEqual(window.foo3, window.bar3)
  • JSON.stringify Level 3

     
    JSON.stringify(window.foo3) === JSON.stringify(window.bar3);