Function arrFindLastIndexOf

  • Searches for an element in an array in reverse order and returns the index of the last occurrence of the element for which the provided testing function returns true. If no such element is found, it returns -1.

    Type Parameters

    • T

    Parameters

    • input: T[]

      The array to search in.

    • predicate: ((value) => boolean)

      The testing function. Takes a value and returns a boolean.

        • (value): boolean
        • Parameters

          • value: T

          Returns boolean

    Returns number

    The index of the last occurrence of the element in the array that passes the test. If no such element is found, it returns -1.

    Example

    const arr = [1, 2, 3, 4, 5, 4, 3];
    arrFindLastIndexOf(arr, (value) => value === 4);
    //=> 5

Generated using TypeDoc