Finding the difference between two sets

We've seen how to combine two sets with the union operation, and find their common elements with the intersection  operation. The logical next step is to see how the sets differ. Next, we'll take a look at how to find out what elements one set has that another doesn't. This operation is called a difference of two sets. An element is in the difference of two sets, if it is in the first set, but not the second.

In this recipe, we'll take a look at how to find the difference between two Set instances.

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.