checking existance of key

Benchmark created on


Setup

const test = {
	1: {
		identifier: 1
	},
	2: {
		identifier: 2
	},
	3: {
		identifier: 3
	},
	4: {
		identifier: 4
	},
	5: {
		identifier: 5
	},
	6: {
		identifier: 6
	},
	7: {
		identifier: 7
	},
	8: {
		identifier: 8
	},
	9: {
		identifier: 9
	},
	10: {
		identifier: 10
	},
	11: {
		identifier: 11
	},
	12: {
		identifier: 12
	},
	13: {
		identifier: 13
	},
	14: {
		identifier: 14
	},
	15: {
		identifier: 15
	}
};

function sampleAccess(access) {
	if (access(4)) return;
	
	test[4];
	
	if (access(20)) return;
	
	test[20];
}

Test runner

Ready to run.

Testing in
TestOps/sec
[] acessor === undefined
sampleAccess((index) => test[index] === undefined);
ready
hasOwnProperty()
sampleAccess((index) => test.hasOwnProperty(index));
ready
Object.hasOwn()
sampleAccess((index) => Object.hasOwn(test, index));
ready

Revisions

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