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