Skip to content
wolfram77 edited this page Mar 26, 2020 · 27 revisions

Gives values present in any array.

Alternatives: compare, compare-update, map, map-update.

array.union(x, y, [fn]);
// x:  an array
// y:  another array
// fn: compare function (a, b)
const array = require('extra-array');

var x = [1, 2, 3, 4];
array.union(x, [2, 3, 5]);
// [1, 2, 3, 4, 5]

var x = [1, 2, 3, 4];
array.union(x, [-2, -3, -5], (a, b) => Math.abs(a) - Math.abs(b));
// [1, 2, 3, 4, -5]

references

Clone this wiki locally