includes()

The includes() method determines whether an array includes a certain element, returning true or false as appropriate.

arr.includes(searchElement)
arr.includes(searchElement, fromIndex)

Parameters

searchElement

The element to search for.

fromIndex

The position in this array at which to begin searching for searchElement. A negative value searches from the index of array.length + fromIndex by asc. Defaults to 0.

var a = [1, 2, 3];
a.includes(2); // true 
a.includes(4); // false

results matching ""

    No results matching ""