title: JavaScript, if statement always executes only the 'else' branch
body: <p>I've an <code>if</code> statement that test the value returned by a function call.
  Even if the value is <code>true</code>, it always executes the <code>else</code> branch.</p>
  
  <p>My code:</p>
  
  <pre><code>var debug = {
      enable: true,
      log: function(msg, tag){
          if(this.enable)
          console.log((tag?"["+tag+"] ":"") + msg);
      }
  };
  
  var checkUser = function(urlServer, user){
      $.couch.urlPrefix = urlServer;
      $.couch.login({
          name: user.name,
          password: user.password,
          success: function(data){
              debug.log("l'utente " + user.name + "è già registrato sul server", "checkUser");
              $.couch.logout({
                  success: function(data){
                      debug.log("logout utente: OK", "checkUser");
                      debug.log(data);
                  },
                  error: function(data){
                      debug.log("logout utente: FAIL", "checkUser");
                      debug.log(data);
                  }
              });
              return true
          },
          error: function(err){
              debug.log("l'utente " + user.name + " NON è registrato sul server", "checkUser");
              return false;
          },
          async: false
      });
  };
  
  // ... code ...
  
  $("input").on("click", function(){
      if( checkUser(urlCouchDbServer, user) ){
          console.log("dopo il controllo l'utente risulta registrato");
      }else{
          console.log("dopo il controllo l'utente NON risulta registrato");
          sigupUser(urlCouchDbServer, user);
      }
  });
  </code></pre>
  
  <p>Why this latest <code>if</code> does not work properly?
  Thanks!</p>