Skip to content
Subhajit Sahu edited this page Feb 4, 2021 · 13 revisions

Gives lists present in any lists. 📦 😺 🏃 📼 🌔 📜 📰 📘

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


lists.union(x, y, [fc]);
// x:  lists
// y:  another lists
// fc: combine function (a, b)
const lists = require('extra-lists');

var x = [['a', 'b', 'c'], [1, 2, 3]];
var y = [['b', 'c', 'd'], [20, 30, 40]];
lists.union(x, y).map(v => [...v]);
// [ [ 'a', 'b', 'c', 'd' ], [ 1, 2, 3, 40 ] ]

lists.union(x, y, (a, b) => b).map(v => [...v]);
// [ [ 'a', 'b', 'c', 'd' ], [ 1, 20, 30, 40 ] ]


References

Clone this wiki locally