Is there a way to access an JavaScript object like this:
var a = {};
a.propertyA.propertyB;
where a.propertyA
is of course undefined
, but I'd like to write a.propertyA.propertyB
assuming a.propertyA
is not undefined
. If a.propertyA
is undefined
, I expect a.propertyA.propertyB
also to be undefined
.
I'm developing with complicate objects, so sometimes I feel like accessing objects with multiple properties at once. I wonder there's a kind of get
method that can be given a default value.
Thank you in advance.