JavaScript Compruebe si no está indefinido
if (typeof myVar !== "undefined") {
console.log("myVar is DEFINED");
}
Grepper
if (typeof myVar !== "undefined") {
console.log("myVar is DEFINED");
}
if(typeof comment === 'undefined') {
alert('Variable "comment" is undefined.');
} else if(comment === null){
alert('Variable "comment" is null.');
}
if ( typeof query !== 'undefined' && query )
{
//do stuff if query is defined and not null
}
else
{
}