Function get

  • Gets the value at path of object. If the resolved value is undefined, the defaultValue is returned in its place.

    Parameters

    • object: any

      The object to query.

    • path: string[]

      The path of the property to get.

    • OptionaldefaultValue: any

      The value returned for undefined resolved values.

    Returns any

    Returns the resolved value.

    5.3.0

    has, hasIn, set, unset

    const object = { 'a': [{ 'b': { 'c': 3 } }] }

    get(object, 'a[0].b.c')
    // => 3

    get(object, ['a', '0', 'b', 'c'])
    // => 3

    get(object, 'a.b.c', 'default')
    // => 'default'
  • Parameters

    • object: any
    • path: string
    • OptionaldefaultValue: any

    Returns any