Sometimes you have several candidates and want the first one that isn’t missing. Use the rule “missing means null or undefined”. Do not skip valid falsy values like 0, '', or false.
function pick(a?: number | null, b?: number | null) {
return a ?? b; // picks a unless it is null/undefined
}
Return whatever type the caller passed in, as long as it was present.
Return the first value that isn’t null or undefined.