_.get(object, path, [defaultValue])
Gets the value at path
of object
. If the resolved value is undefined
, the defaultValue
is returned in its place.
Since
3.7.0
Arguments
object
(Object): The object to query.path
(Array|string): The path of the property to get.[defaultValue]
(*): The value returned forundefined
resolved values.
Returns
(*): Returns the resolved value.
Example
var 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'
当前内容版权归 lodash.com 或其关联方所有,如需对内容或内容相关联开源项目进行关注与资助,请访问 lodash.com .