This is the skeleton of my code :
var myArray: (Array<any> | null);
if (cnd) {
myArray = [];
myArray?.push(elt); // Question 1
myArray[0].key = value; //Question 2
} else {
myArray = null;
}
Question 1 : Why ?
is needed ? myArray has been assigned to an empty array.
Question 2 : What is the syntax to avoid error : Object is possibly null.
Thanks for answer.