In vs Set

Benchmark created on


Setup

const oneArray = ["one", "two", "three", "four", "five", "six", "seven"]

const oneSet = new Set(oneArray)

const two = {
	one: true,
	three: true,
	four: true,
	six: true,
	eight: true,
	nine: true,
	ten: true
}

Test runner

Ready to run.

Testing in
TestOps/sec
Using "in"
oneArray.some((field) => field in two)
ready
Using "Set"
Object.keys(two).some((field) => oneSet.has(field))
ready
Using indexing
oneArray.some((field) => two[field] !== undefined)
ready

Revisions

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