Using && for conditionals in Javascript
<p>I have this:</p>

<pre><code>var field = query("form#"+form.id+" input[name='" + error.field + "']");
if(field.length){
  if( field[0].id ) {
    widget = registry.byId( field[0].id );
    if(widget){
    ...
  }
 }
</code></pre>

<p>I would have thought I could write:</p>

<pre><code>var field = query("form#"+form.id+" input[name='" + error.field + "']");
if(field.length &amp;&amp; field[0].id &amp;&amp; widget = registry.byId( field[0].id) ){
...
}
</code></pre>

<p>But if I use the second, "shortened" form, I get a Javascript error. </p>

<p>Sorry, it would be messy to give a JSFiddle. The problem happens when query() returns 0 values  -- <code>field[0].id</code> &amp;&amp; <code>widget = registry.byId( field[0].id)</code>  were still interpreted.</p>

<p>I thought that I was playing it safe as the second <code>field[0].id</code> would only happen if <code>field.length</code> was <code>&gt; 0</code> and then <code>widget =  registry.byId( field[0].id)</code> would only happen if <code>field[0].id</code>  is true...</p>

<p>What am I missing?</p>

<p>Merc.</p>
