javascript "polymorphic callable objects"
<p>I saw <a href="http://ajaxian.com/archives/javascript-tips-for-rookies-and-gurus">this article on polymorphic callable objects</a> and was trying to get it to work, however it seems that they are not really polymorphic, or at least they do not respect the prototype chain.</p>

<p>This code prints <code>undefined</code>, not <code>"hello there"</code>.</p>

<p>Does this method not work with prototypes, or am I doing something wrong? </p>

<pre><code>var callableType = function (constructor) {
  return function () {
    var callableInstance = function () {
      return callableInstance.callOverload.apply(callableInstance, arguments);
    };
    constructor.apply(callableInstance, arguments);
    return callableInstance;
  };
};

var X = callableType(function() {
    this.callOverload = function(){console.log('called!')};
});

X.prototype.hello = "hello there";

var x_i = new X();
console.log(x_i.hello);
</code></pre>
