title: Subclassing Javascript Arrays. TypeError: Array.prototype.toString is not generic
body: <p>Is it possible to subclass and inherit from javascript Arrays?</p>
  
  <p>I'd like to have my own custom Array object that has all the features of an Array, but contains additional properties.  I'd use <code>myobj instanceof CustomArray</code> to perform specific operations if the instance is my CustomArray.</p>
  
  <p>After attempting to subclass and running into some problems, I found this <a href="http://dean.edwards.name/weblog/2006/11/hooray/" rel="noreferrer">Dean Edwards</a> article that indicates doing this with Array objects doesn't work right. It turns out Internet Explorer doesn't handle it properly. But I'm finding other issues as well (only tested in Chrome so far).</p>
  
  <p>Here's some sample code:</p>
  
  <pre><code>/** 
   *  Inherit the prototype methods from one constructor into another 
   *  Borrowed from Google Closure Library 
   */
  function inherits(childCtor, parentCtor) {
      function tempCtor() {};
      tempCtor.prototype = parentCtor.prototype;
      childCtor.superClass_ = parentCtor.prototype;
      childCtor.prototype = new tempCtor();
      childCtor.prototype.constructor = childCtor;
  },
  
  // Custom class that extends Array class
  function CustomArray() {
      Array.apply(this, arguments);
  }
  inherits(CustomArray,Array);
  
  array = new Array(1,2,3);
  custom = new CustomArray(1,2,3);
  </code></pre>
  
  <p>Entering the following in Chrome's console gives this output:</p>
  
  <pre><code>&gt; custom
  []
  &gt; array
  [1, 2, 3]
  &gt; custom.toString()
  TypeError: Array.prototype.toString is not generic
  &gt; array.toString()
  "1,2,3"
  &gt; custom.slice(1)
  []
  &gt; array.slice(1)
  [2, 3]
  &gt; custom.push(1)
  1
  &gt; custom.toString()
  TypeError: Array.prototype.toString is not generic
  &gt; custom
  [1]
  </code></pre>
  
  <p>Obviously, the objects don't behave the same. Should I give up on this approach, or is there some way to accomplish my goal of <code>myobj instanceof CustomArray</code>?</p>