title: Intercept type error
body: <p>Is there a way to intercept type error and return own value ?
  Consider scenario:
  I have my own lib that in case of undefined or null returns some value</p>
  
  <pre><code>if (typeof value === 'undefined' || value === null) return Nothing;
  </code></pre>
  
  <p>so if you use this</p>
  
  <pre><code>mylib(null) // -&gt; Nothing
  mylib(1) // -&gt; Just(1)
  </code></pre>
  
  <p>That is all good but if I pass in object with un-existing property like this</p>
  
  <pre><code>var a = {};
  a.b = {};
  mylib(a.b.c.d) // -&gt; c is not an Object and does not have property d
  // Uncaught TypeError: Cannot read property 'd' of undefined
  </code></pre>
  
  <p>So what I would like is to intercept type errors and return Nothing instead and I want to do it in native js and I don't want to pass in properties to check in array or delimited string or something. So far I didn't find a way to do it.</p>
  
  <p>I saw some examples of redefining window.onerror() but wondering if there is elegant way of preventing type errors dynamically.</p>