Options
All
  • Public
  • Public/Protected
  • All
Menu

Module array/findLast

Index

References

Functions

References

Renames and re-exports findLast

Functions

  • findLast<T>(fn: ArrPred<T>, list: ArrayLike<T>): T
  • findLast<T>(fn: ArrPred<T>): (list: ArrayLike<T>) => T
  • Returns the last element of the list which matches the predicate, or undefined if no element matches.

    example
     const xs = [{a: 1, b: 0}, {a:1, b: 1}];

    findLast(propEq('a', 1))(xs); //=> {a: 1, b: 1}
    findLast(propEq('a', 4))(xs); //=> undefined

    Type parameters

    • T

    Parameters

    • fn: ArrPred<T>

      The predicate function used to determine if the element is the desired one.

    • list: ArrayLike<T>

      The array to consider.

    Returns T

    The element found, or undefined.

  • Returns the last element of the list which matches the predicate, or undefined if no element matches.

    example
     const xs = [{a: 1, b: 0}, {a:1, b: 1}];

    findLast(propEq('a', 1))(xs); //=> {a: 1, b: 1}
    findLast(propEq('a', 4))(xs); //=> undefined

    Type parameters

    • T

    Parameters

    • fn: ArrPred<T>

      The predicate function used to determine if the element is the desired one.

    Returns (list: ArrayLike<T>) => T

    The element found, or undefined.

      • (list: ArrayLike<T>): T
      • Parameters

        • list: ArrayLike<T>

        Returns T

Generated using TypeDoc