title: Javascript isnull
body: <p>This is a really great function written in jQuery to determine the value of a url field:</p>
  
  <pre><code>$.urlParam = function(name){
      var results = new RegExp('[\\?&amp;]' + name + '=([^&amp;#]*)').exec(window.location.href);
      return results[1] || 0;
  }
  
  // example.com?someparam=name&amp;otherparam=8&amp;id=6
  $.urlParam('someparam'); // name
  $.urlParam('id'); // 6
  $.urlParam('notavar'); // null
  </code></pre>
  
  <p><a href="http://snipplr.com/view/11583/retrieve-url-params-with-jquery/" rel="noreferrer">http://snipplr.com/view/11583/retrieve-url-params-with-jquery/</a></p>
  
  <p>I would like to add a condition to test for null, but this looks kind of klunky:</p>
  
  <pre><code>if (results == null) {
      return 0;
  } else {
      return results[1] || 0;
  }
  </code></pre>
  
  <p>Q: What's the elegant way to accomplish the above if/then statement?</p>