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.

    • Optional defaultValue: any

      The value returned for undefined resolved values.

      Optional

    Returns any

    Returns the resolved value.

    Since

    5.3.0

    See

    has, hasIn, set, unset

    Example

    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
    • Optional defaultValue: any
      Optional

    Returns any