JS: Set.prototype.isDisjointFrom
(new in JS: ECMAScript 2024)
setA.isDisjointFrom(setB)
-
- return true if the union of 2 sets is empty.
- setB can be a Map.
const xx = new Set([4, 5, 6]) const yy = new Set([7, 8]) console.log(xx.isDisjointFrom(yy)) // true
// isDisjointFrom of 2 map's keys const mapA = new Map([[4, 0], [5, 0], [6, 0]]) const mapB = new Map([[7, 0], [8, 0]]) console.log((new Set(mapA.keys())).isDisjointFrom(mapB)) // true