Let's say I have this object (or an array of these objects):
var person = {
    birth: {
        place: {
            country: 'USA'
        }
    }
};
I thought there was a lodash function where I could pass in 'birth.place.country' and get back the value USA.
Is there such a function in lodasdh 3.x, or am I Imagining this?
You could use the _.get function:
_.get(person, 'birth.place.country', 'optionalDefaultValue');
lodash also provides a function called _.result that can also call functions.
Note: for an array of these objects
_.map(people, 'birth.place.country')
provides the same functionality as undefined's answer
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With