Skip to content

isDisjoint

wolfram77 edited this page Apr 11, 2020 · 25 revisions

Checks if arrays have no value in common. 🏃 📦 🌔

Alternatives: compare, map.

array.isDisjoint(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.isDisjoint(x, [2, 5]);
// false

array.isDisjoint(x, [-2, -5]);
// true

array.isDisjoint(x, [-2, -5], (a, b) => Math.abs(a) - Math.abs(b));
// false

references

Clone this wiki locally