Skip to content

difference

Subhajit Sahu edited this page Dec 2, 2022 · 20 revisions

Obtain values not present in another set.

Alternatives: difference, difference$.
Similar: union, intersection, difference, symmetricDifference, isDisjoint.


function difference(x, y)
// x: a set
// y: another set
const set = require('extra-set');

var x = new Set([1, 2, 3, 4, 5]);
var y = new Set([2, 4]);
set.difference(x, y);
// → Set(3) { 1, 3, 5 }

var y = new Set([2, -4]);
set.difference(x, y);
// → Set(4) { 1, 3, 4, 5 }


References

Clone this wiki locally