title: Creating array-like objects in JavaScript
body: <p>In JavaScript, there are objects that pretend to be arrays (or are "array-like").  Such objects are <code>arguments</code>, <code>NodeList</code>s (returned from <code>getElementsByClassName</code>, etc.), and jQuery objects.</p>
  
  <p>When <code>console.log</code>ged, they appear as arrays, but they are not.  I know that in order to be array-like, an object must have a <code>length</code> property.</p>
  
  <p>So I made an "object" like this:</p>
  
  <pre><code>function foo(){
      this.length = 1;
      this[0] = "bar";
  }
  
  var test = new foo;
  </code></pre>
  
  <p>When I <code>console log(test)</code>, I get (as expected) a <code>foo</code> object.  I can "convert" it to an array using</p>
  
  <pre><code>Array.prototype.slice.call(test)
  </code></pre>
  
  <p>But, I don't want to convert it, I want it to be array-like. How do I make an array-like object, so that when it's <code>console.log</code>ged, it appears as an array?</p>
  
  <p>I tried setting <code>foo.prototype = Array.prototype</code>, but <code>console.log(new foo)</code> still shows a <code>foo</code> object, and not an array.</p>