Toggle navigation
MeasureThat
.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
getOwnPropertyNames vs Object.keys vs for ... in
yeah
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36 Edg/119.0.0.0
Browser:
Chrome 119
Operating system:
Windows
Device Platform:
Desktop
Date tested:
2 years ago
for ... in
12.8M/s
getOwnPropertyNames
4.9M/s
keys
4.7M/s
View exact numbers
Test name
Executions per second
✓
for ... in
12,758,334 Ops/sec
getOwnPropertyNames
4,946,674 Ops/sec
keys
4,681,591 Ops/sec
Script Preparation code:
var obj = { $props : ['a','b','c'], a:1, b:2, c:3 }
Tests:
keys
const arr = Object.keys(obj); let n = 0; for (let i = 0; i < arr.length; i++) { const k = arr[i]; if (k.charAt(0) == '$') continue; n++; }
getOwnPropertyNames
const arr = Object.getOwnPropertyNames(obj); let n = 0; for (let i = 0; i < arr.length; i++) { const k = arr[i]; if (k.charAt(0) == '$') continue; n++; }
for ... in
let n = 0; for (const k in obj) { if (k.charAt(0) == '$') continue; n++; }