title: catch null object in js
body: <p>How can i catch the object is null or not an object. Actually i have wrote this line in if condition for solving it, but not working.</p>
  
  <p>But Generating ERROR :- "object is null or not an object"</p>
  
  <pre><code>var preWynum = "";
  function paint(Wynum)
  {
      // alert("Wynum:"+Wynum +", preWynum:"+preWynum);
      if(document.getElementById(preWynum) &amp;&amp; document.getElementById(Wynum))
      {
        document.getElementById(preWynum).style.backgroundColor='white';
        document.getElementById(Wynum).style.backgroundColor='yellow';
      }
  
     preWynum = Wynum; 
  
  }
  </code></pre>
  
  <p>I dont believe why it not running.
   Any other idea ? </p>
  
  <p>preWynum and Wynum is the id of tr(table row).</p>
  
  <p>I want to set background color with yellow to current selected row(that's id is Wynum).</p>