Check variable whether undefined or doesn't exist
<blockquote>
  <p><strong>Possible Duplicate:</strong><br>
  <a href="http://stackoverflow.com/questions/519145/how-can-i-check-whether-a-variable-is-defined-in-javascript">How can I check whether a variable is defined in JavaScript?</a>  </p>
</blockquote>



<p>Say we have a piece of code like this. How would one be able to check whether the variable does exist or not in the case its value might be undefined?</p>

<pre><code>var a = { foo: 'bar' }
a['foo'] = undefined;
// now a['foo'] returns undefined, as it does exist and contains undefined as its value
delete a['foo']
// now a['foo'] still returns undefined, but it doesn't exist
</code></pre>

<p>Thanks.</p>
