Skip to content

Instantly share code, notes, and snippets.

@sajaddp
Last active June 7, 2025 11:22
Show Gist options
  • Save sajaddp/966f4e3efa8d6c75b2ebb02eef068ed2 to your computer and use it in GitHub Desktop.
Save sajaddp/966f4e3efa8d6c75b2ebb02eef068ed2 to your computer and use it in GitHub Desktop.
Removing Array Duplicates in ES6
const array = [1,2,3,3,5,4,8,9,5,2,3,1,2,2,1,1,3,6,4,8,9,1,2,5,3,4,6,9,7,8,9] as const;
const uniqueArray = Array.from(new Set(array)) satisfies typeof array;
const uniqueArray2 = array.reduceRight<number[]>((acc, cur) => acc.includes(cur) ? acc : [cur, ...acc], []);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment