Dupe checks

Benchmark created on


Setup

var sample = Array.from(Array(9000).keys())
function findDuplicatesOld(array) {
	return array.filter((item, index) => array.slice(index + 1).some(elem => elem === item));
}
function findDuplicatesNew(array) {
	return [...new Set(array.filter((item, index) => array.indexOf(item) !== index))]
}

Test runner

Ready to run.

Testing in
TestOps/sec
Old
findDuplicatesOld(sample)
ready
New
findDuplicatesNew(sample)
ready

Revisions

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