Set vs Object (v2)

Revision 2 of this benchmark created on


Setup

let arr = [1,2,3,4,5,6,7,8,1];

Test runner

Ready to run.

Testing in
TestOps/sec
Set
arr.length === new Set(arr).size
ready
Object
let obj = {};
for(let num of arr) {
	if(num in obj) break;
	else obj[num] = true;
}
ready
Object #2
let obj = {};
for (const num of arr) {
	obj[num] = true;
}
ready

Revisions

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