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