Skip to main content

includes

includes() function

Checks if the specified value is equal. (contains)

Signature:
declare function includes<T>(value: unknown, iterable: Iterable<T>): boolean;

declare function includes<T extends readonly []>(value: unknown, iterable: T): false;

declare function includes<T>(value: unknown, iterable: AsyncIterable<T>): Promise<boolean>;

declare function includes<T extends Iterable<unknown> | AsyncIterable<unknown>>(value: unknown): (iterable: T) => ReturnValueType<T, boolean>;

Example

includes('c', 'abcd'); // true
includes('e', 'abcd'); // false
includes(3, [1,2,3,4]); // true
includes(5, [1,2,3,4]); // false