Tobias Wright

I like to build stuff for the internet

Set Composition in Javascript

Learned about Set composition today. Now I’m just looking for the problem this will solve.

In JavaScript, the Set is a built-in object that allows you to store unique values of any type, whether they are primitive values or object references. Here are the key points about Sets:

This means that NaN is considered the same as NaN, and all other values are compared using the semantics of the === operator.

Plus it has a lot of great methods. I’ve really seen it mostly used to remove duplicates from an array like so.

What is new to me is Set composition, right from the MDN site

Read all about Sets