Snips

Reusable Code Snippets

Javascript | Unique Array Using Sets

Edit on Github
sourceArray.reduce((acc, item) => {
  if (!acc.has(item.id)) {
    uniqueArray.push(item);
    acc.add(item.id);
  }

  return acc;
}, new Set());