Array.contains method
Array › contains
Official
Checks if the array contains a specific element.Signature:
contains(target: T): booleanParameters:
| Parameter | Type | Description |
|---|---|---|
| target | T | The element to check for. |
Returns: boolean — true if the element is found, false otherwise.
Example:
console.log([1, 2, 3].contains(2)); // trueconsole.log([1, 2, 3].contains(4)); // false