Property iteration (v3)

Revision 3 of this 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
hasOwnProperty
for (const key in object) {
    if (object.hasOwnProperty(key)) {
         console.log(key);
    }
}
ready
hasOwn
for (const key in object) {
    if (Object.hasOwn(object, key)) {
         console.log(key);
    }
}
ready
entries
for (const [key] of Object.entries(object)) {
    console.log(key);
}
ready
keys
for (const key of Object.keys(object)) {
    console.log(key);
}
ready

Revisions

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