const str = undefined

const restr = str?.name ?? "Unknown";
console.log(restr); // "Unknown"