isArrayItem()function

isArrayItem(list: PossibleArray<T>, item: unknown): item is T
ParamType
listPossibleArray<T>
The array or iterable to search. required
itemunknown
The value to look for. required
Return
item is T
true if item exists in list, narrowing its type.

Is an unknown value an item in a specified array or iterable?

Examples

isArrayItem([1, 2, 3], 2); // true
isArrayItem([1, 2, 3], 9); // false