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