JS, jeśli nie jest niezdefiniowany
if (typeof myVar !== "undefined") {
console.log("myVar is DEFINED");
}
Grepper
if (typeof myVar !== "undefined") {
console.log("myVar is DEFINED");
}
if (typeof myVariable === 'undefined'){
//myVariable is undefined
}
let myVar;
if (myVar === undefined){}
//!! Note: myVar == undefined would also check wether myVar is null
//alternatively
if (typeof myVar === 'undefined'){ }
if(typeof comment === 'undefined') {
alert('Variable "comment" is undefined.');
} else if(comment === null){
alert('Variable "comment" is null.');
}
let id;
if(typeof id === 'undefined') {
console.log("id is undefined...");
}
if (typeof myVariable === 'undefined'){
//myVariable is undefined
}