last finds the last item that matches a predicate. Returns the last item of array if no predicate is provided.

  • Type Parameters

    • T

    Parameters

    • arr: T[]

      An array

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

      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, the last element is returned.

    Returns Option<T>

    The last item that matches the predicate, or None if no item matches.