Object unions can be exclusive when each variant has different keys. The in operator narrows by checking for a property at runtime. If 'email' in c is true, you have the email variant; otherwise, you might have the phone variant.
function isEmail(c: { email: string } | { phone: string }) {
return "email" in c;
}
Return a boolean so callers can branch as needed.
Detect whether a contact carries an email.