New Built-in Classes: Set
Learn about the basics of the new built-in class, sets of JavaScript.
Motivation to bring sets and maps in JavaScript
We often use collections of objects when programming. In other languages, you may have used arrays, lists, sets, associative maps, or dictionaries. Sadly, JavaScript offered only arrays in the past.
When programmers needed a set or a map in JavaScript, they resorted to workarounds. These workarounds made code hard to maintain, and when code resulted in unintended behavior, we had more errors to deal with.
Now, JavaScript offers built-in classes for sets and maps as first-class citizens in the language. We will take a look at sets first and then maps. We will wrap up by looking at some special variations of these two classes for better memory usage.
Using Set
The Array
class that has been ...