Introduction

For our final chapter, we'll be taking a look at two more new, related types. Set and WeakSet, like Map and WeakMap, are collections of other values. However, rather than creating relationships between pairs of values, Set and WeakSet create a relationship between all entries in the collection. These data structures ensure that there are no duplicated entries. If a new item evaluates as equal with another member, it won't be added to the Set.

The recipes in this chapter will illustrate how to implement different behaviors with the set classes.

Get ECMAScript Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.