optional chaning on array length code example
Example 1: conditional chaining chrome
const nameLength = db?.user?.name?.length;
const adminOption = db?.user?.validateAdminAndGetPrefs?.().option;
const optionLength = db?.user?.preferences?.[optionName].length;
const userName = usersArray?.[userIndex].name;
Example 2: optional chaining
let myMap = new Map();
myMap.set("foo", {name: "baz", desc: "inga"});
let nameBar = myMap.get("bar")?.name;
Example 3: optional-chaining operator
if (user?.team?.subscription?.invoices) {
}