Operação de diferença de conjunto de JavaScript
// perform difference operation
// elements of set a that are not in set b
function difference(setA, setB) {
let differenceSet = new Set(setA)
for (let i of setB) {
differenceSet.delete(i)
}
return differenceSet
}
// two sets of fruits
let setA = new Set(['apple', 'mango', 'orange']);
let setB = new Set(['grapes', 'apple', 'banana']);
let result = difference(setA, setB);
console.log(result);
SAMER SAEID