I can test null or undefined with ?? operator :
let test = undefined;
let result = test ?? "null or undefined"
But can I actually get "null" if it is null or "undefined" if it is undefined using ?? somehow ?
CodePudding user response:
Just cast to string?
const test = undefined;
const result = test ?? String(test);
console.log(result);