Get value if all objects in chain exist, get fallback value if not <p>Feel kind of stupid to ask.. I want to get something like this:</p> <pre><code>var value = $scope.settings.paper.font.color || 0; </code></pre> <p>The problem is that some of the middle objects may not exist. </p> <p>Is there an ultimate way to get <strong>value</strong> if all "object chain" exists and get some fallback if not?</p> <p>For example, in line above if all objects exists, we may return value of <strong>color</strong>, but if only $scope.settings exists, and there's no <em>paper</em> object in it, i will get an error, not 0.</p>