Function findLastIndex

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

    Type Parameters

    • T

    Parameters

    • array: T[]

      The array to inspect.

    • predicate: ListIterator<T, boolean>

      The function invoked per iteration.

    • OptionalfromIndex: number

      The index to search from.

    Returns number

    Returns the index of the found element, else -1.

    2.0.0

    find, findIndex, findKey, findLast, findLastKey

    const users = [
    { 'user': 'barney', 'active': true },
    { 'user': 'fred', 'active': false },
    { 'user': 'pebbles', 'active': false }
    ]

    findLastIndex(users, ({ user }) => user == 'pebbles')
    // => 2