Home / Companies / Sonar / Blog / Post Details
Content Deep Dive

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

Blog post from Sonar

Post Details
Company
Date Published
Author
Phil Nash
Word Count
1,280
Language
English
Hacker News Points
115
Summary

The introduction of new Set functions in JavaScript is set to enhance its functionality. These include union, intersection, difference, symmetricDifference, isSubsetOf, isSupersetOf, and isDisjointFrom. While the ES2015 version of JavaScript Sets focused on creating, adding to, removing from, and checking membership, these new functions allow for operations between sets such as finding common elements or determining differences. The proposal for these methods is currently at stage 3 in TC39's process with Chrome 122 (February 2024) and Safari 17 (September 2023) having shipped implementations of these methods. Polyfills are available for older JavaScript engine support, allowing developers to upgrade to spec-compliant implementations of these functions.