Run details:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.99 Safari/537.36
Chrome 67
Mac OS X 10.13.4
Desktop
6 years ago
Test name Executions per second
_.isEqual Level 1 534911.6 Ops/sec
JSON.stringify Level 1 346648.5 Ops/sec
_.isEqual Level 2 349390.6 Ops/sec
JSON.stringify Level 2 344130.2 Ops/sec
_.isEqual Level 3 261999.4 Ops/sec
JSON.stringify Level 3 344156.6 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);