Finding the union of two sets

Now that we've got a good handle on sets, it's time to start performing some set operations. Sets are unordered groups of things; something you might want to do is to combine two groups into one. This operation is called a union of two sets. An element is in the union of two sets, if it exists in either of them.

In this recipe, we'll take a look at how to create a union of 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.