title: Prevent error "is undefined" in if statement
body: <p>My question is about preventing an "variable is undefined" error more effiencitly.</p>
  
  <p>e.g</p>
  
  <p>If I use the following code:</p>
  
  <pre><code>if (array[index] != undefined)
  {
    if (array[index].id == 1)
    {
      // code 
    }
  }
  </code></pre>
  
  <p>It will work fine. But, am I able to use</p>
  
  <pre><code>if (array[index] != undefined &amp;&amp; array[index].id == 1)
  {
   // code
  }
  </code></pre>
  
  <p>without getting an "variable is undefined" error, if <code>array</code> is undefined?</p>
  
  <p>(I can't exactly test this in my code right now because I'm building a client-server application, and I'd have to alter many lines to try it, so I'm asking it here. I'm sorry if it's not appropriate)</p>