if(typeof comment === 'undefined') { alert('Variable "comment" is undefined.'); } else if(comment === null){ alert('Variable "comment" is null.'); }