title: Javascript boolean operation not working
body: <p>I have a really weird problem. I have an if statement like the such below:</p>
  
  <pre><code>$rootScope.changeView = function(view){
      $location.path(view); // path not hash
  };
  
  $rootScope.$on('$routeChangeStart', function (event, next) {
      console.log(next.requireLogin + " " + LoginService.getUserLoggedIn());
      console.log(next.requireLogin &amp;&amp; !LoginService.getUserLoggedIn());
  
      if(next.requireLogin &amp;&amp; !LoginService.getUserLoggedIn()) {
          console.log("No access to panel: not logged in.");
  
          alert("You need to be logged in as an administrator to see this page!");
          event.preventDefault();
  
          $timeout(function () {
              $rootScope.changeView("/");
          }, 500);
      }
  });
  </code></pre>
  
  <p>Where LoginServer.getUserLoggedIn and setUserLoggedIn are this:</p>
  
  <pre><code>this.setUserLoggedIn = function(value){
      sessionStorage.userIsLoggedIn = value;
  };
  
  this.getUserLoggedIn = function() {
      return sessionStorage.userIsLoggedIn;
  };
  </code></pre>
  
  <p>The problem is simple. The If statement is never called, even when next.requireLogin is true and LoginService.getUserLoggedIn() is false. The output in the console is as follows:</p>
  
  <pre><code>true false
  false
  </code></pre>
  
  <p>So apparently "next.requireLogin &amp;&amp; !LoginService.getUserLoggedIn()" evaluates to false, yet both are the correct values? If it helps, in the Chrome console the last line with "false" is highlighted purple.</p>
  
  <p>Does anyone know what's wrong?</p>