Skip to content

includes

The includes() method checks whether an array contains a given element.

Interactive example

Syntax

Classic signature

typescript
function includes<
	GenericArrayValue extends unknown
>(
	input: readonly GenericArrayValue[], 
	value: NoInfer<GenericArrayValue>
): boolean

Curried signature

typescript
function includes<
	GenericArrayValue extends unknown
>(
	value: NoInfer<GenericArrayValue>
): (input: readonly GenericArrayValue[]) => boolean

Parameters

  • input: The array to search in.
  • value: The value to search for in the array.

Return value

true if the array contains the value, false otherwise.

See also

  • indexOf - Returns the index of the first occurrence
  • find - Finds the first element that satisfies a condition

Sources

Released under the MIT license.