Skip to content

includes

includes<T>(iterable, item, comparator?): boolean

Defined in: packages/core/src/iterable/includes.ts:19

Checks whether item occurs in iterable.

Named for the semantics it implements: sameValueZero by default, which is what Array.prototype.includes and Set.prototype.has both use, and unlike indexOf it finds NaN.

Time complexity: O(n), short-circuiting on the first match.

T

Iterable<T>

The iterable to search.

T

The item to search for.

EqualityComparator<T, T> = ...

The equality comparison function to use (default is isEqual with “sameValueZero” strategy, the same as Array.prototype.includes).

boolean

true if a matching item was found, false otherwise.