Sometimes I have:
let a = { b: { c1: { z: false } } }
Other times I have:
let a = { b: { c2: { z: false } } }
I have let n = 'c1'
or let n = 'c2'
I can do this to propagate the undefined:
a?.b[n]?.z
But other than if(a.b) ...
, can I do anything shorthand if b
is undefined?
There isn't a ?[
it seems, and I don't think I can do a['b'][n]?.z
either, because if there is no b then attempting to index n
on it will give cannot read property VALUE_OF_N of undefined ?