Function findLastKey

  • This method is like findKey except that it iterates over elements of a collection in the opposite order.

    Type Parameters

    • T extends object

    Parameters

    • object: T

      The object to inspect.

    • predicate: ObjectIterator<T, boolean>

      The function invoked per iteration.

    Returns string | undefined

    Returns the key of the matched element, else undefined.

    2.0.0

    find, findIndex, findKey, findLast, findLastIndex

    const users = {
    'barney': { 'age': 36, 'active': true },
    'fred': { 'age': 40, 'active': false },
    'pebbles': { 'age': 1, 'active': true }
    }

    findLastKey(users, ({ age }) => age < 40)
    // => returns 'pebbles' assuming `findKey` returns 'barney'