Toggle navigation
MeasureThat
.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
_.isEmpty vs Object.keys.length vs custom isEmpty method (10000) alt is empty
(version: 1)
Comparing performance of:
_.isEmpty vs Object.keys().length vs isEmpty
Created:
one year ago
by:
Guest
Go to the latest result
HTML Preparation code:
<script src="https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.17.4/lodash.min.js"></script>
Script Preparation code:
window.obj = {}; for (var i = 0, len = 10000; i < len; i++) { obj['key' + i] = 'value' + i; } function isEmpty(obj) { for (const prop in obj) return false return true; }
Tests:
_.isEmpty
_.isEmpty(window.obj);
Object.keys().length
Object.keys(window.obj).length === 0;
isEmpty
isEmpty(window.obj)
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (3)
Previous results
Fork
Test case name
Result
_.isEmpty
Object.keys().length
isEmpty
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
one year ago
)
User agent:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36
Browser/OS:
Chrome 131 on Mac OS X 10.15.7
View result in a separate tab
Embed
Embed Benchmark Result
isEmpty
2K/s
Object.keys().length
2K/s
_.isEmpty
2K/s
View exact numbers
Test name
Executions per second
✓
isEmpty
2,428 Ops/sec
Object.keys().length
2,424 Ops/sec
_.isEmpty
2,418 Ops/sec
Related benchmarks
_.isEmpty vs You-Dont-Need-Lodash-Underscore#_isempty
_.isEqual vs Object.is
_.isEmpty vs Object.keys.length vs custom isEmpty method (10)
_.isEmpty vs Object.keys.length vs custom isEmpty method (10) alt is empty
Comments
Confirm delete:
Do you really want to delete benchmark?