Run details:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.121 Safari/537.36
Chrome 85
Mac OS X 10.15.6
Desktop
4 years ago
Test name Executions per second
_.isEmpty 315789.0 Ops/sec
Object.keys().length 314032.1 Ops/sec
Object.values().length pour Laurent 78927.2 Ops/sec
HTML Preparation code:
AخA
 
1
<script src="https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.17.4/lodash.min.js"></script>
Script Preparation code:
x
 
window.obj = {};
for (var i = 0, len = 100; i < len; i++) {
  obj['key' + i] = 'value' + i;
}
Tests:
  • _.isEmpty

     
    _.isEmpty(window.obj);
  • Object.keys().length

     
    Object.keys(window.obj).length === 0;
  • Object.values().length pour Laurent

     
    Object.values(window.obj).length === 0;