Skip to content

Array.contains method

Array › contains

Official

Checks if the array contains a specific element.

Signature:

contains(target: T): boolean

Parameters:

Parameter Type Description
target T The element to check for.

Returns: booleantrue if the element is found, false otherwise.

Example:

console.log([1, 2, 3].contains(2)); // true
console.log([1, 2, 3].contains(4)); // false