Skip to content

Instantly share code, notes, and snippets.

@martingaido
Created July 30, 2020 22:42
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 martingaido/6b58fab1592d1416daad0328eb4530f8 to your computer and use it in GitHub Desktop.
Save martingaido/6b58fab1592d1416daad0328eb4530f8 to your computer and use it in GitHub Desktop.
Remove duplicate values from an iterable object using Set()
/* Remove duplicate values from an iterable object using Set()
x.add()
x.delete()
x.has()
x.clear()
x.size()
*/
const set_one = new Set()
.add('Red')
.add('Yellow')
.add('Blue')
.add('Red'); // duplicated
console.log(set_one);
/* Remove from given iterable */
const set_two = new Set([1, 2, 3, 3, 4, 5, 6, 6]);
console.log(set_two);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment