Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Object.keys vs for ... in (bigger object)
(version: 1)
Comparing performance of:
window.objectKeys vs window.isEmpty
Created:
6 months ago
by:
Guest
Jump to the latest result
Script Preparation code:
window.objectKeys = (value) => { return Object.keys(value).length > 0 } window.isEmpty = (value) => { if (!value) { return true; } for (const key in value) { if (Object.hasOwn(value, key)) { return false; } } return true; }
Tests:
window.objectKeys
const obj = { a: "a", b: "b", c: "c", d: "d", e: "e", f: "f", g: "g", h: "h", i: "i", j: "j", k: "k", l: "l", m: "m", } window.objectKeys(obj)
window.isEmpty
const obj = { a: "a", b: "b", c: "c", d: "d", e: "e", f: "f", g: "g", h: "h", i: "i", j: "j", k: "k", l: "l", m: "m", } window.isEmpty(obj)
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (2)
Previous results
Fork
Test case name
Result
window.objectKeys
window.isEmpty
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
2 months ago
)
User agent:
Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:147.0) Gecko/20100101 Firefox/147.0
Browser/OS:
Firefox 147 on Windows
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
window.objectKeys
6616782.5 Ops/sec
window.isEmpty
6317413.0 Ops/sec
Related benchmarks:
for-in vs object.keys isEmpty
loop-vs-if
check obj empty state with for-in vs object.keys
isEmpty tests
for-in own keys vs object.keys
JustTheseProps
_.isEmpty vs Object.keys.length vs custom isEmpty method (10)
for-in vs object.keys for checking empty
Object.keys vs for ... in
Comments
Confirm delete:
Do you really want to delete benchmark?