Is there a way to catch an attempt to access a non existant property or method?
<p>For instance this code:</p>

<pre><code>function stuff() {
  this.onlyMethod = function () {
    return something;
  }
}

// some error is thrown
stuff().nonExistant();
</code></pre>

<p>Is there a way to do something like PHP's <code>__call</code> as a fallback from inside the object?</p>

<pre><code>function stuff() {
  this.onlyMethod = function () {
    return something;
  }
  // "catcher" function
  this.__call__ = function (name, params) {
    alert(name + " can't be called.");
  }
}

// would then raise the alert "nonExistant can't be called".
stuff().nonExistant();
</code></pre>

<p><strong>Maybe I'll explain a bit more what I'm doing.</strong></p>

<p>The object contains another object, which has methods that should be accessible directly through this object. But those methods are different for each object, so I can't just route them, i need to be able to call them dynamically.</p>

<p>I know I could just make the object inside it a property of the main object <code>stuff.obj.existant()</code>, but I'm just wondering if I could avoid it, since the main object is sort of a wrapper that just adds some functionality temporarily (and makes it easier to access the object at the same time).</p>
