Function findLast

  • This method is like find except that it iterates over elements of collection from right to left.

    Type Parameters

    • T

    Parameters

    • collection: ArrayLike<T>

      The collection to inspect.

    • Optional predicate: string

      The function invoked per iteration.

      Optional
    • Optional fromIndex: number

      The index to search from.

      Optional

    Returns T | undefined

    Returns the matched element, else undefined.

    Since

    5.2.0

    See

    [[find]],[[findIndex]],[[findKey]],[[findLastIndex]],[[findLastKey]]

    Example

    findLast([1, 2, 3, 4], n => n % 2 == 1)
    // => 3
  • Type Parameters

    • T

    Parameters

    • collection: ArrayLike<T>
    • Optional predicate: ((item) => boolean)
      Optional
        • (item): boolean
        • Parameters

          • item: T

          Returns boolean

    • Optional fromIndex: number
      Optional

    Returns T | undefined

  • Type Parameters

    • T

    Parameters

    • collection: ArrayLike<T>
    • Optional predicate: Partial<T>
      Optional
    • Optional fromIndex: number
      Optional

    Returns T | undefined

  • Type Parameters

    • T

    Parameters

    • collection: ArrayLike<T>
    • Optional predicate: any
      Optional
    • Optional fromIndex: number
      Optional

    Returns T | undefined