How to avoid "the property of undefined" error without having huge if statement in JavaScript?
<p>I usually find myself working with deep objects like this:</p>

<pre><code>var x = {
  y: {
    z: {
      a:true
    }
  }
}
</code></pre>

<p>And somewhere in the code:</p>

<pre><code>if( x.y.z.a === true ){
  //do something
}
</code></pre>

<p>And in some cases any of the x,y,z variables could be undefined, in which case you would get "<strong>Cannot read property * of undefined</strong>"</p>

<p>Potential solution is:</p>

<pre><code>if( x &amp;&amp; x.y &amp;&amp; x.y.z &amp;&amp; x.y.z.a === true ){
  //do something
}
</code></pre>

<p>jsfiddle: <a href="http://jsfiddle.net/EcFLk/2/">http://jsfiddle.net/EcFLk/2/</a></p>

<p>But is there any easier/shorter way? Inline solutions (without using special function) would be great. Thanks.</p>
