predictype / predicates/arrays/arrayMembership / arrayMembership
arrayMembership<
T
>(source
,oper
,target
):boolean
Defined in: predicates/arrays/arrayMembership.ts:30
Checks membership conditions for all or some elements in an array, using the specified operation.
T
Type of the array elements.
T
[]
The source array.
The membership operation to perform (e.g. ‘every_equals’, ‘includes’).
T
The value to check for membership.
boolean
True if the membership check is valid according to the operator, otherwise false.
If the operation is not recognized.
const arr1 = [1, 1, 1];
const arr2 = [1, 2, 3];
const value1 = 1;
const value2 = 2;
arrayMembership(arr1, 'every_equals', value1); // true
arrayMembership(arr2, 'includes', value2); // true
Supported Operators: