Skip to content

Instantly share code, notes, and snippets.

@cuneydbolukoglu
Created March 29, 2022 20:40
Show Gist options
  • Save cuneydbolukoglu/89fee2d95e8e5a7814ee700fdfce7cbe to your computer and use it in GitHub Desktop.
Save cuneydbolukoglu/89fee2d95e8e5a7814ee700fdfce7cbe to your computer and use it in GitHub Desktop.
How to Remove Array Duplicates in ES6
const data = [1, 2, 2, 3, 3, 4];
const removeArrayDuplicates = data.reduce(
(unique, item) => (unique.includes(item) ? unique : [...unique, item]),
[]
);
console.log(removeArrayDuplicates);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment