Array filter unique vs Spread set

Benchmark created on


Setup

function uniqFilter(input) {
  return input.filter((value, index, self) => self.indexOf(value) === index);
}

function uniqSet(input) {
	return [...new Set(input)];
}

const input = Array.from({length: 10**6}).map((_, i) => i % 10**3);

Test runner

Ready to run.

Testing in
TestOps/sec
Array filter unique
uniqFilter(input);
ready
Spread set
uniqSet(input);
ready

Revisions

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