Not sure what's wrong with this JavaScript "undefined" check
<p>I thought I had correctly followed the recommendations <a href="http://stackoverflow.com/questions/27509/detecting-an-undefined-object-property-in-javascript">in this question</a> for checking <code>undefined</code>:</p>

<pre><code>if(typeof window.session.location.address.city != "undefined")       
    console.log(window.session.location.address.city);
</code></pre>

<p>But the code above generates this error:</p>

<pre><code> Uncaught TypeError: Cannot read property 'city' of undefined
</code></pre>

<p>What's the correct way to perform this check?</p>
