Optional chaining works with method calls too. Use ?.() to safely call a method that might not exist.
const obj = {};
obj.doSomething?.(); // undefined, no error
const arr = null;
arr?.push?.(1); // undefined, no error
The method only executes if it exists. Otherwise you get undefined.