New Set methods
I’m pleased to learn there are New JavaScript Set methods, as described by Brian Smith on MDN. Node is supporting it with version 22.0.0 (which is too modern for what I´m doing in a current project with Serverless Azure Functions). The Browsers are also supporting it (but Firefox only since version 127, which was released Jun 11, 2024. I think that is as well too modern to use it right now).
intersection()
- returns a new set with elements in both this set and the given set.
union()
- returns a new set with all elements in this set and the given set.
difference()
- returns a new set with elements in this set but not in the given set.
symmetricDifference()
- returns a new set with elements in either set, but not in both.
isSubsetOf()
- returns a boolean indicating if all elements of a set are in a specific set.
isSupersetOf()
- returns a boolean indicating if all elements of a set are in a specific set.
isDisjointFrom()
- returns a boolean indicating if this set has no elements in common with a specific set.
Comments