title: javascript check if null from json
body: <p>Im using the following javascript. it writes fine until it gets to a result which doesn't have a value. in console log it shows this </p>
  
  <blockquote>
    <p>Uncaught TypeError: Cannot read property 'text' of null</p>
  </blockquote>
  
  <p>but my script below doesn't seem to work</p>
  
  <pre><code>            var checkCaption = photo.caption.text;
              if (checkCaption == null) {
                  caption = 'meh';
              } else {
                  caption = photo.caption.text;
              }
  </code></pre>