I'm trying to assign a variable with some object property and if that property doesn't exist than i'm assigning something else , for example:
Lets say our object is : a = {"b":{"c":{"d":"e"}}};
var SomeVar = (a && a.b && a.b.c && a.b.c.d) || OtherValue;
this approach is working as expected and if one of the nested properties doesn't exist i won't get an error like :
Uncaught TypeError: Cannot read property 'c' of undefined
Is this the right approach? or there is a better way to do that?