Hallo dedlfix,
if (foo && foo.bar && foo.bar.qux)völlig aus, um zu testen, ob foo.bar (als Objekt) existiert und in foo.bar.qux was sinnvolles drinsteht
Für sowas würde ich immer einen Helper schreiben, der mir den ganzen Boilerplate abnimmt, z.B. sowas:
function getPath(obj, key, dfault = undefined) {
  const path = key.split(/\./);
  let i = 0;
  while (obj && i < path.length) {
    obj = obj[path[i++]];
  }
  return obj === undefined ? dfault : obj;
}
console.log(getPath({}, "a.0.c"));
console.log(getPath({ a: [{ c: 'd' }]}, "a.0.c"));
console.log(getPath({}, "a.0.c", 'd'));
LG,
CK
 nicht angemeldet
 nicht angemeldet Orlok
 Orlok Rolf B
 Rolf B