I've got the following code:
const result = A.field_1.subfield_2
How can I evaluate result to null
when A
in null (or A.field_1
) and avoid null errors? I was wondering if there's a more elegant approach rather than doing
if (A != null && A.field_1 != null) { ...
E.g., what if there're 10 fields.