Check out example codes for "optional chaining". It will help you in understanding the concepts better.

Code Example 1

const array = [1,2,3,4,5];
let arrItem = array?.[4]; 

console.log(arrItem); /// 5

Code Example 2

let myMap = new Map();
myMap.set("foo", {name: "baz", desc: "inga"});

let nameBar = myMap.get("bar")?.name;

Code Example 3

/* 
* optional chaining (?.) allows me to write code that stops 
* running when we encounter a null or undefined value
*/

function tryGetFirstElement<T>(arr?: T[]) {
    return arr?.[0];
    // equivalent to
    //   return (arr === null || arr === undefined) ?
    //       undefined :
    //       arr[0];
}

Learn ReactJs, React Native from akashmittal.com