Skip to content

Instantly share code, notes, and snippets.

@thisaurel
Created July 16, 2020 19:13
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 thisaurel/ae7bd5d08384f1162a0abaa0541e16e3 to your computer and use it in GitHub Desktop.
Save thisaurel/ae7bd5d08384f1162a0abaa0541e16e3 to your computer and use it in GitHub Desktop.
Set is a new data object introduced in ES6. Because Set only lets you store unique values.
When you pass in an array, it will remove any duplicate values.
const myArray = [0, 1, 2, 2, 3, 3, 3, 4, 5, 5, 5, 6, 7, 7, 7];
const removeDuplicatesFromArray = Array.from(new Set(myArray));
console.log(removeDuplicatesFromArray);
Result: (8) [0,1,2,3,4,5,6,7]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment