Function indexOf

  • This method is like findIndex except that it searches for a given value directly, instead of using a predicate function.

    Returns

    The index of the found value, else -1

    Example

    indexOf([1, 2, 1, 2], 2)
    // 1

    // Search from a `start` index.
    indexOf([1, 2, 1, 2], 2, 2)
    // 3

    See

    Type Parameters

    • T

    Parameters

    • obj: T[]

      The array to inspect.

    • value: T

      The value to find

    • Optional start: number = 0

      The index to search from.

    Returns number

Generated using TypeDoc