title: How do I make a callable JS object with an arbitrary prototype?
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/340383/can-a-javascript-object-have-a-prototype-chain-but-also-be-a-function">Can a JavaScript object have a prototype chain, but also be a function?</a>  </p>
  </blockquote>
  
  
  
  <p>I'm looking to make a callable JavaScript object, with an arbitrary prototype chain, but without modifying Function.prototype.</p>
  
  <p>In other words, this has to work:</p>
  
  <pre><code>var o = { x: 5 };
  var foo = bar(o);
  assert(foo() === "Hello World!");
  delete foo.x;
  assert(foo.x === 5);
  </code></pre>
  
  <p>Without making any globally changes.</p>