Object.has vs Reflect.has

Benchmark created on


Description

test the functions

Setup

const testObject = {
	a: 1,
	b: 2
}

Test runner

Ready to run.

Testing in
TestOps/sec
Object.hasOwnProperty
for(let i=0; i <= 1000000; i++){
	
	let test = Object.hasOwnProperty(testObject, "a");
}
ready
Object.hasOwn
for(let i=0; i <= 1000000; i++){
	
	let test = Object.hasOwn(testObject, "a");
}
ready
chaining operator
for(let i=0; i <= 1000000; i++){
	
	let test = (testObject?.a);
}
ready
Reflect.has
for(let i=0; i <= 1000000; i++){
	
	let test = Reflect.has(testObject, "a");
}
ready

Revisions

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