title: How do I insert something into a prototype chain?
body: <p>I have a "class" that is essentially a beefed-up <code>Array</code>:</p>
  
  <pre><code>function NamedArray(name) {
    var result = [];
    result.name = name;
    return result;
  };
  
  var cheeses = new NamedArray('Cheeses');
  </code></pre>
  
  <p>This works great. What doesn't work is adding a prototype for this "class":</p>
  
  <pre><code>NamedArray.prototype = {
    nameInAllCaps: function() {
      return this.name.toUpperCase();
    }
  };
  
  cheeses.nameInAllCaps();
  =&gt; TypeError: Object #&lt;Object&gt; has no method 'nameInAllCaps'
  </code></pre>
  
  <p>My first thought was just to mix the "prototype" into the <code>result</code> <code>Array</code>:</p>
  
  <pre><code>function NamedArray(name) {
    var result = [];
    result.name = name;
    for (var prop in NamedArray.prototype) {
      if (NamedArray.prototype.hasOwnProperty(prop) {
        result[prop] = NamedArray.prototype[prop];
      }
    }
    return result;
  };
  </code></pre>
  
  <p>This works, but it causes each instance to have its own copy of the prototype properties. Is there a way to <em>insert</em> NamedArray.prototype into the prototype chain of the <code>result</code> <code>Array</code>?</p>