Set vs Object

Benchmark created on


Test runner

Ready to run.

Testing in
TestOps/sec
Set
let arr = [1,2,3,4,5,6,7,8,1];

arr.length === new Set(arr).size
ready
Object
let arr = [1,2,3,4,5,6,7,8,1];
let obj = {};
for(let num of arr) {
	if(num in obj) break;
	else obj[num] = true;
}
ready

Revisions

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