title: How to best safely use console.log and console.warn?
body: <p>I'm working to take over a code base that tests to make sure <code>console.warn</code> exists like this:</p>
  
  <pre><code>if (window.console) {                                                                                                                                                                                                                                                      
    console.warn("shhaabang");                                                                                                                                                                                                    
  }                                                                                                                                                                                                                                                                          
  </code></pre>
  
  <p>However, my problem with this is that it works only in the browser where you have a window object. This would seem to work too.</p>
  
  <pre><code>if (console &amp;&amp; typeof console.warn == 'function') {                                                                                                                                                                                                                                                      
    console.warn("shhaabang");                                                                                                                                                                                                    
  }
  </code></pre>
  
  <p>Are there any downsides to this method? Are there any better methods that don't assume the existence of <code>window</code>? Should I just see if window or global exists first and check both?</p>
  
  <p><strong>CLARIFICATION</strong> It should be obvious at the least that I'm testing this in something that doesn't have the <code>window</code> object. But, to be explicit <strong>I am running this in node.js as well as the browser</strong></p>