array.includes vs set.has (v5)

Revision 5 of this benchmark created on


Setup

const itemsArray = [];
const itemsSet = new Set();
for (let i = 0; i < 4; i++) {
	let s = "";
	for (let j = 0; j < 6; j++) s += String(i)
	itemsArray.push(s)
	itemsSet.add(s)
}

Test runner

Ready to run.

Testing in
TestOps/sec
Array.includes()
itemsArray.includes("1")
itemsArray.includes("2")
itemsArray.includes("3")
itemsArray.includes("4")
ready
Set.has()
itemsSet.has('1')
itemsSet.has('2')
itemsSet.has('3')
itemsSet.has('4')
ready

Revisions

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