title: How to check chain of hasOwnProperty in objects
body: <p>I have json like this </p>
  
  <pre><code>var a = {
      "name": "test1",
      "redisData": {
          "redisIp": "127.0.0.1",
          "dbSetting": {
              "dbIp": "127.0.0.1",
              "dbUserName": "root",
              "dbUserPassword": "root",
          },
          "otherData":{
              "email":"a@gmail.com"
          }
      }
  }
  </code></pre>
  
  <p>So i have to push this data in database when all the data present in all key
  for that purpose i have to validate that data like this </p>
  
  <pre><code>if (a.hasOwnProperty("redisData")) {
      if (a.redisData.hasOwnProperty("dbSetting")) {
          if (a.redisData.dbSetting.hasOwnProperty("dbIp")) {
              if (a.redisData.dbSetting.dbIp) {
                  // now insert in to database
              } else {
                  alert('DB server Ip missing');
              }
          } else {
              alert('DB server Ip missing');
          }
      } else {
          alert('DB server Ip missing');
      }
  } else {
      alert('DB server Ip missing');
  }
  </code></pre>
  
  <p>But this code looks ugly. Do we have better way to avoid multiple if condition and chaining of <code>hasownproperty</code>.</p>