Object entry iteration

Benchmark created on


Setup

const object = {
	one: 1,
	two: 2,
	three: 3,
	four: 4,
	five: 5,
};

Test runner

Ready to run.

Testing in
TestOps/sec
for...in with hasOwnProperty
for (const key in object) {
    if (object.hasOwnProperty(key)) {
         console.log(key, object[key]);
    }
}
ready
for...in with hasOwn
for (const key in object) {
    if (Object.hasOwn(object, key)) {
         console.log(key, object[key]);
    }
}
ready
for...of over entries
for (const [key, value] of Object.entries(object)) {
    console.log(key, value);
}
ready

Revisions

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