title: If statement checking not null is being ignored
body: <p>Below is a portion of code I'm using to get the href or src of an image of known class or id. The console.log() returns null, even though it is in an if statement checking that the attribute later used isn't null.
  Of course, trying to get href or src of null doesn't end well.</p>
  
  <pre><code>for(var i = 0 ; (i &lt; sitelist[site].img_id.length) &amp;&amp; (img === undefined) ; i++)
  {
      if(document.getElementById(sitelist[site].img_id[i]) !== undefined)
      {
          if(document.getElementById(sitelist[site].img_id[i]) !== null)
          {
              console.log(document.getElementById(sitelist[site].img_class[i]));
              if(document.getElementById(sitelist[site].img_class[i]).href !== undefined)
              {
                  img =   document.getElementById(sitelist[site].img_class[i]).href;
              }
              if(document.getElementById(sitelist[site].img_class[i]).src !== undefined)
              {
                  img =   document.getElementById(sitelist[site].img_class[i]).src;
              }
          }
      }
  }
  </code></pre>
  
  <p>Is there a specific way of checking if something is null, or is the problem elsewhere?</p>