title: Why am I getting a "variable undefined" error when comparing a variable to undefined?
body: <p>I looked at this issue:</p>
  
  <p><a href="https://stackoverflow.com/questions/2647867/how-to-determine-if-variable-is-undefined-or-null">How to determine if variable is &#39;undefined&#39; or &#39;null&#39;?</a></p>
  
  <p>But it did not help.</p>
  
  <p>I have the following code:</p>
  
  <pre><code>    if (_modeID != 8 &amp;&amp; _modeID != 9)
          // do something
  </code></pre>
  
  <p><code>_modeID</code> is defined and assigned a value in a separate file all together.</p>
  
  <p>I'm encountering a bug where, for some reason, <code>var _modeID = someIntVal;</code> is never executed, so when the <code>if</code> statement above runs there is no <code>_modeID</code> at all.</p>
  
  <p>I expanded it to be <code>if (_modeID === null || _modeID === undefined || (_modeID != 8 &amp;&amp; _modeID != 9)</code> but this still throws the following error:</p>
  
  <blockquote>
    <p>ReferenceError - Java Script Error : '_modeID' is undefined</p>
  </blockquote>
  
  <p>I was hoping that either the first or second condition would evaluate to true in this case but apparently not. Can anyone shed some light as to what I'm doing wrong?</p>
  
  <p>Is <code>var _modeID = undefined; if (_modeID === undefined) ...</code> not the same as simply <code>if (_modeID === undefined) ...</code> assuming those two snippets were "complete" files?</p>