Skip to content

Instantly share code, notes, and snippets.

@tararoutray
Created August 29, 2021 13:26
Show Gist options
  • Save tararoutray/0d1bf7d5cd8054499d3c6ecaf0e48651 to your computer and use it in GitHub Desktop.
Save tararoutray/0d1bf7d5cd8054499d3c6ecaf0e48651 to your computer and use it in GitHub Desktop.
// You can create a JavaScript Set by:
// → Option 1: Passing an Array to new Set()
const languages = new Set(['Javascript', 'Python', 'PHP']);
// → Option 2: Create a Set and use add() to add values
const languages = new Set();
languages.add('Javascript');
languages.add('Python');
languages.add('PHP');
// → Option 3: Create a Set and use add() to add variables
const js = 'Javascript';
const py = 'Python';
const php = 'PHP';
const languages = new Set();
languages.add(js);
languages.add(py);
languages.add(php);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment