Function firstIndex

Returns the index of the first element in the array that satisfies the provided testing function. Otherwise None is returned.

  • Type Parameters

    • T

    Parameters

    • arr: T[]

      An array

    • predicate: ((value: T, index: number, array: T[]) => boolean)

      A predicate function.

        • (value, index, array): boolean
        • Parameters

          • value: T
          • index: number
          • array: T[]

          Returns boolean

    • OptionalthisArg: any

      If provided, it will be used as the this value for each invocation of predicate. If it is not provided, undefined is used instead.

    Returns Option<number>

    The index of the first item that matches the predicate, or None if no item matches.