Check if variable is undefined not working
<p>I want to check if a variable is undefined and quickly found some stackoverflow answers that said the correct way to do it is to test if(variable==null).  But in Chrome I am getting an error saying:
Uncaught ReferenceError: xdate is not defined</p>

<p>Huh? The whole reason I am testing is so I don't get errors like this.  And I did it just like the approved stackoverflow answers.
Here is my code snippet.</p>

<pre><code>        if (xdate == null){
          var dateadd = "";
        } else {
          var dateadd = "&amp;date="+date;
        }
</code></pre>