codemarch
codemarch

@codemarch

23 Tweets 2 reads Aug 29, 2022
Learn Set in JavaScript.
Complete Explanation:
Thread🧵
1. What is Set ?
➡️A JavaScript Set is a collection of unique values.
➡️A set cannot contain duplicate values.
2. Create JavaScript Set.
➡️Passing an Array to a new Set()
➡️Create a new Set and use add() to add values
➡️Create a new Set and use add() to add variables
3. The new Set() Method.
➡️Creates a new Set.
4. Pass an Array to the new Set() constructor
5. Create a Set and add literal values
6. Access Set Elements.
➡️We can access Set elements using the values() method.
7. typeof
➡️Sets are Objects , Therefore , typeof returns object
8. instanceof Set
➡️The instanceof operator tests to see if the prototype property of a constructor appears anywhere in the prototype chain of an object.
9. The values() Method.
➡️The values() method returns an Iterator object containing all the values in a Set.
10. The keys() Method.
➡️A Set has no keys.
therefore, keys() returns the same as values().
11. has() method.
➡️we can check if there is an element inside that Set using has() method.
12. Adding New Elements.
➡️You can add elements to a Set using the add() method.
13. The delete() method.
➡️The delete() method removes a specific element from a Set.
14. The clear() method.
➡️The clear() method removes all elements from a Set.
15. for...of loop.
16. forEach
17. Set Union Operation.
➡️Union Set is the set made by combining the elements of two sets.
18. Set Intersection Operation
➡️create a set that contains those elements of set A that are also in set B.
19. Set Difference Operation
➡️It means the set that consists of the elements of A which are not elements of B.
20. Set Subset Operation.
➡️set A is a subset of a set B if all elements of A are also elements of B.
If you enjoyed reading this thread, please do the following:
1. Like the thread❤️
2. Retweet the first tweet.🔃
3. Follow me and enable notifications: ✅
@CodeMarch
Thank you for reading all the way through.
Download our free JavaScript Resources ebook Here:
codemarch.gumroad.com

Loading suggestions...