Toggle navigation
MeasureThat
.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
Loop through object keys
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:135.0) Gecko/20100101 Firefox/135.0
Browser:
Firefox 135
Operating system:
Mac OS X 10.15
Device Platform:
Desktop
Date tested:
one year ago
for...in Loop
33.4M/s
Object.keys() with for
31.1M/s
Object.keys() with forEach
18.5M/s
Object.keys with for...of
17.2M/s
Object.entries() with for...of
9.7M/s
View exact numbers
Test name
Executions per second
✓
for...in Loop
33,420,386 Ops/sec
Object.keys() with for
31,143,414 Ops/sec
Object.keys() with forEach
18,477,936 Ops/sec
Object.keys with for...of
17,162,752 Ops/sec
Object.entries() with for...of
9,706,823 Ops/sec
HTML Preparation code:
<!--your preparation HTML code goes here-->
Script Preparation code:
let items = { one: { label: 'One' }, two: { label: 'Two' }, three: { label: 'Three' }, four: { label: 'Four' } } function doStuff(e) {}
Tests:
for...in Loop
for (const key in items) { if (items.hasOwnProperty(key)) { doStuff(key) } }
Object.keys() with for
const keys = Object.keys(items); for (let i = 0; i < keys.length; i++) { doStuff(keys[i]) }
Object.entries() with for...of
for (const [key, value] of Object.entries(items)) { doStuff(key) }
Object.keys with for...of
for (const key of Object.keys(items)) { doStuff(key) }
Object.keys() with forEach
Object.keys(items).forEach(key => { doStuff(key) })