Searching

    We typically use the following methods to search for elements in an array:

    • find
    • findIndex
    • indexOf
    • lastIndexOf
    • includes

    We can search for an element using find, or the element's index using findIndex. Both of these methods take a predicate function (a function that takes an element and returns a boolean) as an argument.

    Index search with ===

    We can search for an element's index using indexOf and lastIndexOf. These use === equality to compare elements.

    Existence

    We can check if an element exists using includes. The includes method uses SameValueZero (similar to ===) to check for equality.