Skip to content
Subhajit Sahu edited this page Mar 17, 2020 · 27 revisions

Gives union of first array with another.

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