Take the code below, is there an easier/better way to check for the existence of myProp3? Imagine that myProp1 and myProp2 also only exist if myProp3 exists. I have run into a few API's that do this and it's a bear to check for the existence of these sub properties down a long chain.
var myObj = {
myProp1: {
myProp2: {
myProp3: 'myProp3'
}
}
}
if (myObj.myProp1 && myObj.myProp1.myProp2 && myObj.myProp1.myProp2.myProp3 && myObj.myProp1.myProp2.myProp3 == 'myProp3') {
//do something
}