Array.prototype.includes

Determines whether an array includes a certain element.

Syntax

includes(element, startIndex?)

Parameters

Return value

Returns true if the array contains the element, false if it doesn’t.

Examples

[1, 2, 3].includes(1)
true
[1, 2, 3].includes(42)
false
["coffee", "tea", "juice"].includes("tea")
true
["coffee", "tea", "juice"].includes("milk")
false