Run details:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.212 Safari/537.36
Chrome 90
Mac OS X 10.14.6
Desktop
3 years ago
Test name Executions per second
_.isEmpty 230929.4 Ops/sec
Object.keys().length 283775.0 Ops/sec
Object.values().length 115192.0 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[`123${i}`] = 'value' + i;
}
Tests:
  • _.isEmpty

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

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

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