Gets the value at path of object. If the resolved value is undefined, the defaultValue is returned in its place.
path
object
undefined
defaultValue
The object to query.
The path of the property to get.
Optional
The value returned for undefined resolved values.
Returns the resolved value.
3.7.0
has, hasIn, set, unset
const object = { 'a': [{ 'b': { 'c': 3 } }] }get(object, 'a[0].b.c')// => 3get(object, ['a', '0', 'b', 'c'])// => 3get(object, 'a.b.c', 'default')// => 'default' Copy
const object = { 'a': [{ 'b': { 'c': 3 } }] }get(object, 'a[0].b.c')// => 3get(object, ['a', '0', 'b', 'c'])// => 3get(object, 'a.b.c', 'default')// => 'default'
Gets the value at
path
ofobject
. If the resolved value isundefined
, thedefaultValue
is returned in its place.