In JavaScript, we can do this
const someValue = null;
const myVal = someValue ?? "use this string if undefined or null";
and the result is:
console.log(myVal); // "use this string if undefined or null"
Is there a way I can check for null or undefined in an if statement without having to do
if(myVal !== null && myVal !== undefined) {
// do something
}
? I cannot do a simple truthy check if(myVal){}
because zero is a valid value for this variable.