JavaScript Array includes() method
determines if an element exists in an array

includes() method determines if an element exists in an array.

syntax

includes(element, start)

element The value to search for.

start (optional). Start position at which to start searching.

Negative start position counts back from the end of the array.

includes() method returns true if an array contains a specified element.

includes() method returns false if the element is not found.

includes() method is case sensitive.

includes() method when used on sparse arrays, iterates empty slots as if they have the value undefined.

syntax 1 description
determine if an element exists in myArray
myArray.includes(element)
syntax 2 description
determine if an element exists in myArray from start position
myArray.includes(element, start)