Test name | Executions per second |
---|---|
_.isEmpty | 230577.4 Ops/sec |
Object.keys().length | 279508.1 Ops/sec |
Object.values().length | 79174.1 Ops/sec |
<script src="https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.17.4/lodash.min.js"></script>
window.obj = {};
for (var i = 0, len = 100; i < len; i++) {
obj[`123${i}`] = 'value' + i;
}
_.isEmpty(window.obj);
Object.keys(window.obj).length === 0;
Object.values(window.obj).length === 0;