Skip to content

Instantly share code, notes, and snippets.

@kevboutin
Created October 17, 2023 15:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kevboutin/26f7dc005b04b3d7e691e0d0a36ce3fd to your computer and use it in GitHub Desktop.
Save kevboutin/26f7dc005b04b3d7e691e0d0a36ce3fd to your computer and use it in GitHub Desktop.
Remove duplicates from an array
const removeDuplicates = (arr) => [...new Set(arr)];
const arr = [1, 2, 3, 4, 5, 3, 1, 2, 5];
const distinct = removeDuplicates(arr);
console.log(distinct); // [1, 2, 3, 4, 5]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment