Array.prototype.includes vs Set.prototype.has

Benchmark created on


Setup

const testArray = new Array(250).fill(0);

for (let i = 0; i < testArray.length; i += 1) {
	testArray[i] = i;
}

const testSet = new Set(testArray);
const randomValue = Math.floor(Math.random() * testArray.length + 1);

Test runner

Ready to run.

Testing in
TestOps/sec
Array.protype.includes
testArray.includes(randomValue);
ready
Set.prototype.has
testSet.has(randomValue);
ready

Revisions

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