Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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