Key check (v2)

Revision 2 of this benchmark created on


Setup

const target = {
	foo: "bar",
	baz: "bonk"
};


const key = "foo";
const key2 = "bar";

Test runner

Ready to run.

Testing in
TestOps/sec
in operator
key in target;
key2 in target;
ready
Reflect
Reflect.has(target, key);
Reflect.has(target, key2);
ready
hasOwn
Object.hasOwn(target, key);
Object.hasOwn(target, key2);
ready
Direct access
typeof(target[key]) === "undefined"
typeof(target[key2]) === "undefined"
ready

Revisions

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