Check if a variable is undefined in javascript if(typeof variable_here === 'undefined'){ // your code here. };