Skip to content

difference

Subhajit Sahu edited this page Dec 5, 2022 · 16 revisions

Obtain entries not present in another map.

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


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

var x = new Map([['a', 1], ['b', 2], ['c', 3], ['d', 4], ['e', 5]]);
var y = new Map([['b', 2], ['d', 4]]);
map.difference(x, y);
// → Map(3) { 'a' => 1, 'c' => 3, 'e' => 5 }

var y = new Map([['b', -2], ['d', -4]]);
map.difference(x, y);
// → Map(3) { 'a' => 1, 'c' => 3, 'e' => 5 }


References

Clone this wiki locally