Property iteration

Benchmark created on


Test runner

Ready to run.

Testing in
TestOps/sec
hasOwnProperty
const object = { one: 1, two: 2, three: 3, four: 4, five: 5 };

for (const key in object) {
    if (object.hasOwnProperty(key)) {
         console.log(key);
    }
}
ready
hasOwn
const object = { one: 1, two: 2, three: 3, four: 4, five: 5 };

for (const key in object) {
    if (Object.hasOwn(object, key)) {
         console.log(key);
    }
}
ready
entries
const object = { one: 1, two: 2, three: 3, four: 4, five: 5 };

for (const [key] of Object.entries(object)) {
    console.log(key);
}
ready
keys
const object = { one: 1, two: 2, three: 3, four: 4, five: 5 };

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.