Define a function with a prototype chain
<p>Suppose I have an object <code>X</code> defined as</p>

<pre><code>var X = function () {};
X.prototype.doSomething = function () {};
X.prototype.doSomethingElse = function () {};
</code></pre>

<p>Is it possible to construct a <strong>function</strong> <code>f</code> so that <code>f instanceof X</code>?
Note that I must also be able to do <code>f()</code> without a <code>TypeError</code>.</p>

<hr>

<p>In Mozilla, I can do exactly what I want with <code>__proto__</code>:</p>

<pre><code>var f = function () {};
f.__proto__ = new X;
</code></pre>

<p>However, that is (1) nonstandard and (2) deprecated. <a href="https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Object/Proto" rel="nofollow">MDN's page for <code>__proto__</code></a> suggests using <code>Object.getPrototypeOf</code> instead, but what I'm really looking for is an <code>Object.setPrototypeOf</code> (which doesn't exist, though the idea is brought up in <a href="https://bugs.ecmascript.org/show_bug.cgi?id=264" rel="nofollow">this bug report</a>).</p>

<p>A cheap approximation to what I want is</p>

<pre><code>var f = function () {};
jQuery.extend(f, new X);
</code></pre>

<p>Unfortunately, this does not make <code>f instanceof X</code> true (nor would I
expect it to!).</p>
