Verifique definir ou indefinido em 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