How to check if a variable is set in Javascript?
<p>I have this object/array thing:</p>

<pre><code>var states = {};

states["CA"] = new State("CA", "California");
states["AR"] = new State("AR", "Arizona");
....
</code></pre>

<p>How can I check if <code>states["AL"]</code> has been set or not? Will the following work (in all browsers)?</p>

<pre><code>if (states["AL"] == undefined)
   alert("Invalid state");
</code></pre>
