title: Which is the best way to check if an object has property
body: <p>I want to ask which is the right way to check if an ajax response object has a property .
  I googled and what I found is that there are different ways to approach this.</p>
  
  <p>For example:</p>
  
  <pre><code>    if(ajaxResponse.hasOwnProperty('someProperty')){
         //do blah blah
      }
  </code></pre>
  
  <p>but there are other ways for sure, for example :</p>
  
  <pre><code>    if(typeof ajaxResponse.someProperty !== 'undefined')){
         //do blah blah
      }
  </code></pre>
  
  <p>So I am guessing there are some pros and cons can you please share these with me.</p>
  
  <p>Thanks </p>