JavaScript — Make Your Code Cleaner With Lodash
Netanel Basal
1136

or you could just not bother with lodash at all and say this, which would return .street if it was defined, or the default if not

let street = person && person.address && person.address.street || "the default"

or since you are using Es6, you could use destructuring, but sadly I think this only works with one depth of undefined object.

let {address:{street:t="default"}} = person; 
Like what you read? Give Bruce Mcpherson a round of applause.

From a quick cheer to a standing ovation, clap to show how much you enjoyed this story.