predictype / arrays / arrayIntersection
arrayIntersection<
T
>(source
,oper
,target
):boolean
Defined in: predicates/arrays/arrayIntersection.ts:28
Checks if two arrays are disjoint or intersect, using the specified operation.
T
Type of the array elements.
T
[]
The source array.
The intersection operation to perform (e.g. ‘disjoint’, ‘intersects’).
T
[]
The target array to check against the source.
boolean
True if the intersection check is valid according to the operator, otherwise false.
If the operation is not recognized.
const arr1 = [1, 2, 3];
const arr2 = [4, 5, 6];
const arr3 = [2, 4, 6];
arrayIntersection(arr1, 'disjoint', arr2); // true
arrayIntersection(arr1, 'intersects', arr3); // true
Supported Operators: