Vérification si VAR n'est pas définie JS

if(typeof x !== 'undefined'){
  alert("Variable x is defined.");
}