Iterate over Object.keys vs for-in

Benchmark created on


Setup

const obj = {
	a: 5,
	b: 6,
	c: undefined
}

Test runner

Ready to run.

Testing in
TestOps/sec
object.keys
let val;
for (const key of Object.keys(obj)) {
	val = obj[key];
}
ready
in
let val;
for (const key in obj) {
	val = obj[key]
}
ready

Revisions

You can edit these tests or add more tests to this page by appending /edit to the URL.