Options
All
  • Public
  • Public/Protected
  • All
Menu

Module findKey

Index

References

Functions Object

References

Renames and re-exports findKey

Object Functions

  • findKey<V>(object: Record<string, V>, predicate?: Predicate<V>): string
  • findKey(object: any, predicate?: any[]): string
  • findKey(object: any, predicate?: string): string
  • This method is like find except that it returns the key of the first element predicate returns truthy for instead of the element itself.

    since

    5.2.0

    see

    find, findIndex, findLast, findLastIndex, findLastKey

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

    findKey(users, ({ age }) => age < 40)
    // => 'barney' (iteration order is not guaranteed)

    Type parameters

    • V

    Parameters

    • object: Record<string, V>

      The object to inspect.

    • Optional predicate: Predicate<V>

      The function invoked per iteration.

    Returns string

    Returns the key of the matched element, else undefined.

  • Parameters

    • object: any
    • Optional predicate: any[]

    Returns string

  • Parameters

    • object: any
    • Optional predicate: string

    Returns string