optional chaining vs await code example
Example 1: conditional chaining chrome
const nameLength = db?.user?.name?.length; // property
const adminOption = db?.user?.validateAdminAndGetPrefs?.().option; // functions
const optionLength = db?.user?.preferences?.[optionName].length; // dynamic property
const userName = usersArray?.[userIndex].name; // on arrays
Example 2: optional chaining
const array = [1,2,3,4,5];
let arrItem = array?.[4];
console.log(arrItem); /// 5