Function arrFindLast

  • Searches for the last element in an array that satisfies a provided testing function.

    Type Parameters

    • T

      The type of elements in the input array.

    Parameters

    • input: T[]

      The array to search within.

    • predicate: ((value) => boolean)

      The function to test each element for a condition.

        • (value): boolean
        • Parameters

          • value: T

          Returns boolean

    Returns T | undefined

    The last element in the array that satisfies the provided testing function. Otherwise, undefined if no elements satisfy the testing function.

    Example

    const numbers = [1, 2, 3, 4, 5, 6];
    arrFindLast(numbers, num => num % 2 === 0);
    //=> 6

Generated using TypeDoc