Toggle navigation
MeasureThat
.net
Create a benchmark
Tools
Feedback
Feature Requests
FAQ
Register
Log In
Run results for:
for-in vs for-of on object
compare perf of the constructions for (key in obj) for (key in Object.keys(obj))
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/145.0.0.0 Safari/537.36
Browser:
Chrome 145
Operating system:
Windows
Device Platform:
Desktop
Date tested:
6 months ago
Benchmark engine:
Benchmark.js
for-in
5/s
for-of-keys
4/s
View exact numbers
Test name
Executions per second
✓
for-in
5 Ops/sec
for-of-keys
4 Ops/sec
Script Preparation code:
var obj = { a: 1, b: 2, c: 3, d: 4, e: 5, f: 6, g: 7, h: 8, i: 9, };
Tests:
for-in
for (var i = 0; i < 10000; i++) { for (var key in obj) { console.log(key); } }
for-of-keys
for (var i = 0; i < 10000; i++) { for (var key of Object.keys(obj)) { console.log(key); } }