Sprawdź zdefiniuj lub niezdefiniowane w JavaScript

if (typeof variable !== 'undefined' || typeof variable ==='undefined') {
     //the variable is either defined or not defined 
  	 //in both conditions the code will be executed
}
Jaimin Patel