Removing Duplicates

Benchmark published by System on

Description

Compare Set vs filter+indexOf.

Setup

const arr = Array.from({length: 1000}, () => Math.floor(Math.random() * 100));

Test Runner

Initializing...

Testing in
Test CaseOps/sec
Set + Spread
const unique = [...new Set(arr)];
ready
Array.from(Set)
const unique = Array.from(new Set(arr));
ready
filter & indexOf
const unique = arr.filter((v, i, a) => a.indexOf(v) === i);
ready

Revisions

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

Revision 1
publishedby Systemon