Cookie Consent by Free Privacy Policy Generator ๐Ÿ“Œ Mastering data with 7 new JavaScript Set methods

๐Ÿ  Team IT Security News

TSecurity.de ist eine Online-Plattform, die sich auf die Bereitstellung von Informationen,alle 15 Minuten neuste Nachrichten, Bildungsressourcen und Dienstleistungen rund um das Thema IT-Sicherheit spezialisiert hat.
Ob es sich um aktuelle Nachrichten, Fachartikel, Blogbeitrรคge, Webinare, Tutorials, oder Tipps & Tricks handelt, TSecurity.de bietet seinen Nutzern einen umfassenden รœberblick รผber die wichtigsten Aspekte der IT-Sicherheit in einer sich stรคndig verรคndernden digitalen Welt.

16.12.2023 - TIP: Wer den Cookie Consent Banner akzeptiert, kann z.B. von Englisch nach Deutsch รผbersetzen, erst Englisch auswรคhlen dann wieder Deutsch!

Google Android Playstore Download Button fรผr Team IT Security



๐Ÿ“š Mastering data with 7 new JavaScript Set methods


๐Ÿ’ก Newskategorie: Programmierung
๐Ÿ”— Quelle: dev.to

In this article, I will be spilling the beans on the coolest, latest methods that probably will turn the Set object into a rockstar. I noticed these new methods in July and finally was able to test them in Safari. All of them are fresh ways to play with data, do crazy intersections, and make unions so smooth you'll wonder how you ever lived without them.

So, 7 new Set methods are under construction now and I will show you the way they interact with data:

  • difference()
  • intersection()
  • isDisjointFrom()
  • isSubsetOf()
  • isSupersetOf()
  • symmetricDifference()
  • union()

Now, let's delve into these methods and see how they elevate the power of Sets in handling data.

We will be working on these two wonderful Sets containing the employees of two best offices of the Dunder Mifflin paper company:


const scrantonOfficeEmployees = new Set([ "Michael Scott", "Jim Halpert", "Pam Beesly", "Dwight Schrute", "Angela Martin", "Stanley Hudson", "Phyllis Smith", "Ryan Howard", "Kelly Kapoor", "Oscar Martinez", "Kevin Malone", "Meredith Palmer", "Creed Bratton", "Toby Flenderson", "Jan Levinson" ]);


const stamfordOfficeEmployees = new Set([ "Jim Halpert", "Andy Bernard", "Karen Filippelli", "Josh Porter", "Tony Gardner" ]);


const dunderMifflinEmployees = new Set([...scrantonOfficeEmployees, ...stamfordOfficeEmployees]); 

  • Theย difference()ย method ofย Set instances takes a set and returns a new set containing elements in this set but not in the given set:

dunderMifflinEmployees.difference(scrantonOfficeEmployees);

// Output: Set (4) {"Andy Bernard", "Karen Filippelli", "Josh Porter", "Tony Gardner"}

  • The intersection() method of Set instances takes a set and returns a new set containing elements in both this set and the given set:

stamfordOfficeEmployees.intersection(scrantonOfficeEmployees);  

// Output: Set (1) {"Jim Halpert"}

  • The symmetricDifference() method of Set instances takes a set and returns a new set containing elements which are in either this set or the given set, but not in both:

stamfordOfficeEmployees.symmetricDifference(scrantonOfficeEmployees);  

// Output:  Set (18) {"Andy Bernard", "Karen Filippelli", "Josh Porter", "Tony Gardner", "Michael Scott", "Pam Beesly", "Dwight Schrute", "Angela Martin", "Stanley Hudson", "Phyllis Smith", "Ryan Howard", "Kelly Kapoor", "Oscar Martinez", "Kevin Malone", "Meredith Palmer", "Creed Bratton", "Toby Flenderson", "Jan Levinson"}

  • The union() method of Set instances takes a set and returns a new set containing elements which are in either or both of this set and the given set:

stamfordOfficeEmployees.union(scrantonOfficeEmployees);  

// Output: Set (19) {"Jim Halpert", "Andy Bernard", "Karen Filippelli", "Josh Porter", "Tony Gardner", "Michael Scott", "Pam Beesly", "Dwight Schrute", "Angela Martin", "Stanley Hudson", "Phyllis Smith", "Ryan Howard", "Kelly Kapoor", "Oscar Martinez", "Kevin Malone", "Meredith Palmer", "Creed Bratton", "Toby Flenderson", "Jan Levinson"}

  • The isSubsetOf() method of Set instances takes a set and returns a boolean indicating if all elements of this set are in the given set:

new Set(["Michael Scott", "Jim Halpert"]).isSubsetOf(scrantonOfficeEmployees);  

// Output: true  

  • The isSupersetOf() method of Set instances takes a set and returns a boolean indicating if all elements of the given set are in this set:

scrantonOfficeEmployees.isSupersetOf(new Set(["Michael Scott", "Jim Halpert"])); 

// Output: true  

  • The isDisjointFrom() method of Set instances takes a set and returns a boolean indicating if this set has no elements in common with the given set:

stamfordOfficeEmployees.isDisjointFrom(dunderMifflinEmployees);  

// Output: false  

Stay tuned for further updates and enhancements to the Set object's capabilities. You can keep track of all the details on the official Mozilla documentation.

...



๐Ÿ“Œ Mastering data with 7 new JavaScript Set methods


๐Ÿ“ˆ 45.13 Punkte

๐Ÿ“Œ Mastering JavaScript: A Comprehensive Guide to Essential Methods and Latest Features


๐Ÿ“ˆ 31.25 Punkte

๐Ÿ“Œ Use JavaScript's New Set Composition Methods Without Polyfills


๐Ÿ“ˆ 29.57 Punkte

๐Ÿ“Œ Mastering JavaScript Screen Capture: Essential Tips for Taking Screenshots | JavaScript Projects


๐Ÿ“ˆ 27.03 Punkte

๐Ÿ“Œ Mastering JavaScript: Unveiling the Power of DOM Manipulation and the JavaScript Object Model


๐Ÿ“ˆ 27.03 Punkte

๐Ÿ“Œ JavaScript console methods for better debugging - ๐Ÿ”ฎ Unlocking JavaScript Magic


๐Ÿ“ˆ 26.44 Punkte

๐Ÿ“Œ From Probabilistic to Predictive: Methods for Mastering Customer Lifetime Value


๐Ÿ“ˆ 23.85 Punkte

๐Ÿ“Œ Mastering Global Functions in Laravel: Easy Methods for Versions 8,9,10,11.


๐Ÿ“ˆ 23.85 Punkte

๐Ÿ“Œ Mastering the Art of Debugging in Magento 2: Essential Methods for a Smooth eCommerce Experience


๐Ÿ“ˆ 23.85 Punkte

๐Ÿ“Œ Mastering Map data structure in JavaScript


๐Ÿ“ˆ 22.97 Punkte

๐Ÿ“Œ Mastering JavaScript Data Types: A Complete Guide for Web Developers


๐Ÿ“ˆ 22.97 Punkte

๐Ÿ“Œ All the new javascript array methods you missed in 2023


๐Ÿ“ˆ 21.96 Punkte

๐Ÿ“Œ ECMAScript 2023 Spec for JavaScript Includes New Methods for Arrays


๐Ÿ“ˆ 21.96 Punkte

๐Ÿ“Œ Mastering JavaScript: A Journey Through the Top 5 GitHub Repositories


๐Ÿ“ˆ 19.62 Punkte

๐Ÿ“Œ Mastering Object-Oriented Programming in JavaScript: Best Practices and Examples


๐Ÿ“ˆ 19.62 Punkte

๐Ÿ“Œ Mastering the Art of Debugging JavaScript Functions: Tips and Tricks for Smooth Functionality


๐Ÿ“ˆ 19.62 Punkte

๐Ÿ“Œ Mastering Error Handling in JavaScript


๐Ÿ“ˆ 19.62 Punkte

๐Ÿ“Œ Mastering JavaScript: A Comprehensive Interview Guide for Students


๐Ÿ“ˆ 19.62 Punkte

๐Ÿ“Œ Unlocking JavaScript Design Patterns: Mastering Singleton for Ultimate Code Efficiency


๐Ÿ“ˆ 19.62 Punkte

๐Ÿ“Œ Mastering React: Essential JavaScript Concepts for Web Developers


๐Ÿ“ˆ 19.62 Punkte

๐Ÿ“Œ Mastering ES2019: A Deep Dive into Five Key JavaScript Features


๐Ÿ“ˆ 19.62 Punkte

๐Ÿ“Œ Mastering Asynchronous JavaScript: A Comprehensive Guide


๐Ÿ“ˆ 19.62 Punkte

๐Ÿ“Œ JavaScript Arrays & HashMaps: Mastering the Most Asked LeetCode Problems in Coding Interviews


๐Ÿ“ˆ 19.62 Punkte

๐Ÿ“Œ JavaScript Tricks for Efficient Coding: Mastering Techniques Every Developer Should Know


๐Ÿ“ˆ 19.62 Punkte

๐Ÿ“Œ Mastering JavaScript Interviews: The Ultimate Guide


๐Ÿ“ˆ 19.62 Punkte

๐Ÿ“Œ Mastering JavaScript Functions: The Core Foundation


๐Ÿ“ˆ 19.62 Punkte

๐Ÿ“Œ Mastering Javascript One-Liners to Look Like a Pro


๐Ÿ“ˆ 19.62 Punkte

๐Ÿ“Œ Ensuring Reliability in Web Services: Mastering Idempotency in Node.js and JavaScript


๐Ÿ“ˆ 19.62 Punkte

๐Ÿ“Œ Mastering the JavaScript switch Statement


๐Ÿ“ˆ 19.62 Punkte

๐Ÿ“Œ Mastering JavaScript: Essential Concepts and Best Practices for Developers


๐Ÿ“ˆ 19.62 Punkte

๐Ÿ“Œ Mastering JavaScript Generators: Understanding and Using the Power of Pausable Functions


๐Ÿ“ˆ 19.62 Punkte

๐Ÿ“Œ Mastering Async/Await: Simplifying JavaScript's Async Operations


๐Ÿ“ˆ 19.62 Punkte

๐Ÿ“Œ Mastering Real-World Functional Programming in JavaScript: 10 Scenarios Demystified


๐Ÿ“ˆ 19.62 Punkte

๐Ÿ“Œ Mastering JavaScript: Multiple Ways to Generate a Two-Dimensional Array


๐Ÿ“ˆ 19.62 Punkte











matomo