title: How to check if a variable is empty in JavaScript?
body: <pre class="lang-js prettyprint-override"><code>var characterName = document.getElementById("pilotName").value;
  var characterID = 0;
  var charSecStatus = 0;
  var corpName = " ";
  var allianceName = " ";
  
  
  //callback
  makeRequest('https://api.eveonline.com/eve/CharacterID.xml.aspx?names=' + characterName, function() {
    if (xmlhttp.status == OK_RESPONSE) {
  
      //read character info
      characterID = xmlhttp.responseXML.getElementsByTagName("row")[0].getAttribute("characterID");
  
      makeRequest('https://api.eveonline.com/eve/CharacterInfo.xml.aspx?characterID=' + characterID, function() {
  
        if (xmlhttp.status == OK_RESPONSE) {
  
          //read character info 
          characterID = xmlhttp.responseXML.getElementsByTagName("characterID")[0].innerHTML;
          charSecStatus = xmlhttp.responseXML.getElementsByTagName("securityStatus")[0].innerHTML;
          corpName = xmlhttp.responseXML.getElementsByTagName("corporation")[0].innerHTML;
          allianceName = (xmlhttp.responseXML.getElementsByTagName("alliance")[0] || {
            innerHTML: ""
          }).innerHTML;
        }
      });
    }
  });
  </code></pre>
  
  <p>(partial code pictured, no bracketspam pls)
  I'm trying to check if the "alliance" variable is empty because certain '"corp" are not in "alliances" and it would be critical error on website if it tried to display an empty variable, so is there a way to check if allianceName is empty after retrieving it from the XML tree and setting it to like "No Alliance" if it IS empty?
  Thanks </p>