Union, intersection, difference, and more are coming to JavaScript Sets | Sonar

February 19, 2024

The JavaScript Set was introduced to the language in the ES2015 spec, but it has always seemed incomplete. That’s about to change.Sets are collections of values where each value may only appear once. In the ES2015 version of the Set, the available functionality revolved around creating, adding to, removing from, and checking the membership of a Set. If you wanted to operate on or compare more than one set, you had to write your own functions. Thankfully, TC39—the committee established to work on the ECMAScript spec—and the browsers have been working on this. We are now seeing functions like union, intersection and difference in JavaScript implementations.

Source: Union, intersection, difference, and more are coming to JavaScript Sets | Sonar

There’s much more to JavaScript than many developers are often exposed to–Sets, Maps, WeakSets, WeakMaps. Here popular Web Directions speaker Phil Nash looks at new features of sets coming to JavaScript.