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.

    • Optionalpredicate: string

      The function invoked per iteration.

    • OptionalfromIndex: number

      The index to search from.

    Returns T | undefined

    Returns the matched element, else undefined.

    5.2.0

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

    findLast([1, 2, 3, 4], n => n % 2 == 1)
    // => 3
  • 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.

    • Optionalpredicate: (item: T) => boolean

      The function invoked per iteration.

    • OptionalfromIndex: number

      The index to search from.

    Returns T | undefined

    Returns the matched element, else undefined.

    5.2.0

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

    findLast([1, 2, 3, 4], n => n % 2 == 1)
    // => 3
  • 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.

    • Optionalpredicate: Partial<T>

      The function invoked per iteration.

    • OptionalfromIndex: number

      The index to search from.

    Returns T | undefined

    Returns the matched element, else undefined.

    5.2.0

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

    findLast([1, 2, 3, 4], n => n % 2 == 1)
    // => 3
  • 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.

    • Optionalpredicate: any

      The function invoked per iteration.

    • OptionalfromIndex: number

      The index to search from.

    Returns T | undefined

    Returns the matched element, else undefined.

    5.2.0

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

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