In JavaScript (or TypeScript), if I'm going to reference something like:
return myObj1.myObj2.myObj3.myProperty;
to be safe, I guard it with something like:
if (myObj1 && myObj2 && myObj3)
return myObj1.myObj2.myObj3.myProperty;
else
return null;
Is there a more concise way of just getting null from the above reference without surrounding it by an if?
Please note, since I'll be using this in a TypeScript app, some solutions may not work with dynamic object definition.
Thanks.