Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
Object.keys vs for ... in (bigger object)
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0.1 Safari/605.1.15
Browser:
Safari 26
Operating system:
Mac OS X 10.15.7
Device Platform:
Desktop
Date tested:
6 months ago
Test name
Executions per second
window.objectKeys
388286048.0 Ops/sec
window.isEmpty
53174352.0 Ops/sec
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)