Sets

    A set is an unordered collections of values. Each value must be unique (it can appear at most once), and uniqueness is determined by (roughly) === comparison.

    The main APIs are:

    • add
    • has
    • delete

    For sample implementions of common set operations, like intersection and difference, see: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set#Implementing_basic_set_operations

    Creating sets

    Working with sets

    When working with sets, we commonly convert them to and from arrays, since arrays have more built-in methods for transforming the contents.

    Converting an array to a set and back is a convenient way to remove duplicates