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 (Windows NT 10.0; Win64; x64; rv:147.0) Gecko/20100101 Firefox/147.0
Browser:
Firefox 147
Operating system:
Windows
Device Platform:
Desktop
Date tested:
2 months ago
Test name
Executions per second
window.objectKeys
6616782.5 Ops/sec
window.isEmpty
6317413.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)