Skip to content

Instantly share code, notes, and snippets.

@rishisidhu
Created July 10, 2020 13:09
Show Gist options
  • Save rishisidhu/cd4a40dbcb3378c09b5a1b8123c0d666 to your computer and use it in GitHub Desktop.
Save rishisidhu/cd4a40dbcb3378c09b5a1b8123c0d666 to your computer and use it in GitHub Desktop.
Modern JS ES6+ features - Sets
//Create set from an array
var set1 = new Set([1, 2, 2, 3, 3, 3, 4, 4, 4, 4]);
console.log(set1);
//Add a new element to it
set1.add(5);
console.log(set1);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment