Chapter 6.  Sets

So far, you have learned about sequential data structures such as arrays (lists), stacks, queues, and linked lists (and their variants). In this chapter, we will cover a data structure called sets, which is also a sequential data structure that does not allow duplicated values.

In this chapter, you will learn how to create a set data structure, to add and remove values, and also to search whether a value already exists. You will learn how to perform mathematical operations such as union, intersection, and difference. You will also learn how to use the native ES6 (ECMAScript 6) Set class.

Structuring a dataset

A set is a collection of items that are unordered and consists of unique elements (meaning they cannot be repeated). This ...

Get Learning JavaScript Data Structures and Algorithms - Second Edition 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.