September 2024
Beginner to intermediate
985 pages
35h 37m
English
In programming, a set is a data structure similar to a list in which values may occur only once; that is, duplicate values are not allowed.
Sets are available since ES2015 and are represented by the new Set object. Whether two values are equal is checked according to the same rules as for the === operator—that is, strict equality, considering both value and type of a variable.
To create a set, you simply use the Set constructor function. As with maps, the value passed can be an array (or an iterable object) that contains the initial values to be added to the set. In Listing 4.113, for example, a set is created that contains five strings as values. The duplicate string Kyuss is copied into the set only ...
Read now
Unlock full access