4.17.11
3.10.1
2.4.2
1.3.1

_.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

argument
object
path
[defaultValue]
type
Object
(Array|string)
*
description
The object to query.
The path of the property to get.
The value returned for `undefined` resolved values.

Returns

(array)

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'
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'