JavaScript — Make Your Code Cleaner With Lodash
Netanel Basal
1136

What about try and catch?

let street;

try{

street = person.address.street

}catch(err){

street = null

}

or

let street = (()=>{ try{return person.address.street}catch(err){return null}})()

Like what you read? Give Charles Chang a round of applause.

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