Gets the value at path of object. If the resolved value is undefined, the defaultValue is returned in its place.
path
object
undefined
defaultValue
5.3.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'
The object to query.
The path of the property to get.
Optional
The value returned for undefined resolved values.
Returns the resolved value.
Gets the value at
path
ofobject
. If the resolved value isundefined
, thedefaultValue
is returned in its place.Since
5.3.0
See
has, hasIn, set, unset
Example