Created
December 12, 2022 02:09
-
-
Save jslnriot/2e9cf374da575e1bdad3f56aa5e2962f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// create a new set | |
let mySet = new Set(); | |
// add some values to the set | |
mySet.add(1); | |
mySet.add("hello"); | |
mySet.add({x: 10, y: 20}); | |
// check if a value is in the set | |
console.log(mySet.has(1)); // true | |
console.log(mySet.has("hello")); // true | |
console.log(mySet.has({x: 10, y: 20})); // false (object equality is not checked) | |
// get the number of values in the set | |
console.log(mySet.size); // 3 | |
// remove a value from the set | |
mySet.delete("hello"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment