Does javascript use optimization in boolean expressions?
<p>I have strange error when I decided to build ordinary web-form validation with classic javascript. There are several "onblur" handlers for input text fields and one "form-submit" handler. </p>

<p>When I use them like that:</p>

<pre><code>function loginCheck() {
  ... return true of false 
}

function passwordCheck() { 
   ...
}

function formValidation() {
  return loginCheck() &amp;&amp; passwordCheck();
}
</code></pre>

<p>It doesn't work as I expect: "passwordCheck" never called if loginCheck is failed! </p>

<p>Finally I have workaround </p>

<pre><code>function formValidation() {
  ok = loginCheck();
  ok &amp;= passwordCheck();
  return ok;
}
</code></pre>

<p>Now password check is executed. But when I choose:</p>

<pre><code>function formValidation() {
      ok = loginCheck();
      ok = ok &amp;&amp; passwordCheck();
      return ok;
    }
</code></pre>

<p>passwordCheck is never called again if loginCheck failed. </p>

<p>Moreover: loginCheck &amp; passwordCheck return boolean values, but &amp;= operator covert it to "0" or "1". "0" doesn't work for my <code>onsubmit="return checkForm"</code> handler.   I have to convert my &amp;= result to boolean once again:</p>

<pre><code>function formValidation() {
      ok = loginCheck();
      ok &amp;= passwordCheck();
      return ok != 0;
    }
</code></pre>

<p>It is a normal behavior for javascript engines ? </p>
