title: Local scope Function prototype override
body: <p>It is trivial to add prototypes to all <code>Function</code>s:</p>
  
  <pre><code>Function.prototype.foo = function () { return 'bar'; };
  (new Function).foo();  // 'bar'
  </code></pre>
  
  <p>However, it is also bad practice to assign things to a global object's prototype, due to cross-module object reliance concerns, partially leading to the demise to earlier versions of <em>prototype.js</em>.</p>
  
  <p>Suppose I want all of <em>my</em> functions to have the method <code>foo</code>. I would do something similar to this:</p>
  
  <pre><code>(function () {
      var Fn = Function;
      Fn.prototype.foo = function () { return 'bar'; };
  
      (new Fn).foo();  // 'bar'
  }());
  
  (new Function).foo()  // also 'bar'. this is bad!
  </code></pre>
  
  <p>Unfortunately, this affects <code>Function</code>'s prototype as well, because Function was scoped by reference.</p>
  
  <p>The usual "copy value" approach for passing primitive values into IIFEs would also fail, because <code>Function</code> itself is an object.</p>
  
  <pre><code>(function (Fn) {
      Fn.prototype.foo = function () { return 'bar'; };
  
      (new Fn).foo();  // 'bar'
  }(Function));
  
  
  Function.foo  // function () { return 'bar'; }
  </code></pre>
  
  <p>Given these examples, is it true that it is impossible to extend <em>selected</em> functions' prototypes, without affecting all other functions outside my scope?</p>