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 |
<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['key' + i] = 'value' + i;
}
_.isEmpty(window.obj);
Object.keys(window.obj).length === 0;
Object.values(window.obj).length === 0;