title: Catching "NullPointerExceptions" in JavaScript
body: <p>I'm writing quite a bit of code in Prototype.js which returns null if a DOM-id wasn't found.</p>
  
  <pre><code>$("someId").show();
  </code></pre>
  
  <p>If <code>someId</code> doesn't exist, a method will be called on null, which halts the entire program, in effect disabling all JS  effects after the error. I could just check for null before executing such a statement, but this is getting tiring.</p>
  
  <p>I would like to catch an exception but I'm not sure which one its is. MDC lists the following ECMA Script error types, but on first glance none of them seem to be what I want:</p>
  
  <pre><code>* Error
  * EvalError
  * RangeError
  * ReferenceError
  * SyntaxError
  * TypeError
  * URIError
  * DOMException
  * EventException
  * RangeException
  </code></pre>
  
  <p>Also, do browsers have a unified way of dealing with a method call on null?</p>