predictype / arrays / arrayIndexMembership
arrayIndexMembership<
T
>(source
,oper
,index
,target
):boolean
Defined in: predicates/arrays/arrayIndexMembership.ts:31
Checks if the value at a specific index in an array is (or is not) included in a target array, using the specified operation.
T
Type of the array elements.
T
[]
The source array.
The membership operation to perform (e.g. ‘at_index_in’).
number
The index in the array to check.
T
[]
The array of values to check for inclusion/exclusion.
boolean
True if the membership check is valid according to the operator, otherwise false.
If the operation is not recognized.
const arr = [10, 20, 30];
const idx1 = 1;
const idx2 = 2;
const values = [10, 20];
arrayIndexMembership(arr, 'at_index_in', idx1, values); // true
arrayIndexMembership(arr, 'at_index_not_in', idx2, values); // true
Supported Operators: