Skip to content

symmetricDifference

Subhajit Sahu edited this page Jun 18, 2020 · 14 revisions

Gives entries not present in both lists. 🏃 📼 📦 🌔 📒

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

lists.symmetricDifference(x, y);
// x: lists
// y: another lists
const lists = require('extra-lists');

var x = [['a', 'b', 'c', 'd'], [1, 2, 3, 4]];
var y = [['c', 'd', 'e', 'f'], [30, 40, 50, 60]];
lists.symmetricDifference(x, y).map(c => [...c]);
// [ [ 'a', 'b', 'e', 'f' ], [ 1, 2, 50, 60 ] ]

var y = [['d', 'e', 'f'], [40, 50, 60]];
lists.symmetricDifference(x, y).map(c => [...c]);
// [ [ 'a', 'b', 'c', 'e', 'f' ], [ 1, 2, 3, 50, 60 ] ]

references

Clone this wiki locally