Verificação de JavaScript se não for indefinido
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 id;
if(typeof id === 'undefined') {
console.log("id is undefined...");
}
if(typeof x !== 'undefined'){
alert("Variable x is defined.");
}
if ( typeof query !== 'undefined' && query )
{
//do stuff if query is defined and not null
}
else
{
}
if (angular.isDefined(var){
//myVariable is undefined
}