title: Checking 'undefined' or 'null' of any Object
body: <p>I am working on Angular project and time to time I used to have check <code>undefined</code> or <code>null</code> over Object or it's properties. Normally I use lodash <code>_.isUndefined()</code> see example below:</p>
  
  <pre><code>this.selectedItem.filter(i =&gt; {
      if(_.isUndefined(i.id)) {
        this.selectedItem.pop();
      }
  })
  </code></pre>
  
  <p>I couldn't see any problem with it. But I had discussion with my colleague during review of above code. He was telling me that if <code>i</code> gets <code>undefined</code> before the <code>if</code> statement then it will throw the exception. Instead he suggested me to always check <code>i</code> or <code>i.id</code> like this:</p>
  
  <pre><code>if(!!i &amp;&amp; !!i.id) {
        this.selectedItem.pop();
  }
  </code></pre>
  
  <p>I am convinced what he was trying to say unlike his way of checking <code>undefined</code> in above code. But then I was thinking what is the purpose of lodash <code>_.isUndefined</code>?</p>
  
  <p>Could anyone please let me know what is the best or clean way to do it. Because for me <code>!!i &amp;&amp; !!i.id</code> is not readable at all.</p>
  
  <p>Many thanks in advance.</p>