Run details:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4484.7 Safari/537.36 OPR/78.0.4072.0 (Edition developer)
Opera 78
Windows
Desktop
3 years ago
Test name Executions per second
_.isEmpty 230577.4 Ops/sec
Object.keys().length 279508.1 Ops/sec
Object.values().length 79174.1 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;