Optional Chaining
The optional chaining operator (?.)
enables us to access potentially null or undefined properties. We can use this for method calls as well.
obj?.property;
obj.member?.property;
obj.method?.();
obj.arr?.[index];
The optional chaining operator (?.)
enables us to access potentially null or undefined properties. We can use this for method calls as well.
obj?.property;
obj.member?.property;
obj.method?.();
obj.arr?.[index];