Skip to content

difference

Subhajit Sahu edited this page Dec 22, 2022 · 15 revisions

Obtain entries not present in another entries.

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


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

var x = [["a", 1], ["b", 2], ["c", 3], ["d", 4], ["e", 5]];
var y = [["b", 2], ["d", 4]];
[...entries.difference(x, y)];
// → [ [ "a", 1 ], [ "c", 3 ], [ "e", 5 ] ]

var y = [["b", -2], ["d", -4]];
[...entries.difference(x, y)];
// → [ [ "a", 1 ], [ "c", 3 ], [ "e", 5 ] ]


References

Clone this wiki locally