Key check (v3)

Revision 3 of this benchmark created on


Setup

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


const key = "foo";

const hasOwn = Object.prototype.hasOwnProperty;

Test runner

Ready to run.

Testing in
TestOps/sec
in operator
if (key in target) {
	target.baz = target[key]
}
ready
Reflect
if (Reflect.has(target, key)) {
	target.baz = target[key]
}
ready
hasOwn
if (Object.hasOwn(target, key)) {
	target.baz = target[key]
}
ready
hasOwnProperty
if (hasOwnProperty.call(target, key))
 {
	target.baz = target[key]
}
ready

Revisions

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