![]() |
VOOZH | about |
Lodash _.get() method is a utility function that retrieves the value of a nested property from an object safely. It allows you to specify a path to the property and provides a default value if the property is undefined or does not exist.
Lodash _.get() method is used to get the value at the path of the object. If the resolved value is undefined, the default value is returned in its place.
_.get(object, path, [defaultValue]);Return Value: This method returns the resolved value
Example 1: In this example, we are accessing the value of an object using the path in the _.get() method
Output:
3
Example 2: In this example, we are accessing the value of an object using the path in the _.get() method but the keys are in a sequential manner
Output:
3
Example 3: In this example, we are accessing the value of an object using the path in the _.get() method having a defalt value as "default"
Output:
'default'