title: Which takes less memory: a Javascript array or Javascript object?
body: <p>If I have a Javascript list which will have only numeric keys, which takes less memory?</p>
  
  <pre><code>var array = [];
  array[0] = 'hello';
  array[5] = 'world';
  array[50] = 'foobar';
  
  var obj = {};
  obj[0] = 'hello';
  obj[5] = 'world';
  obj[50] = 'foobar';
  </code></pre>
  
  <p>I don't know a ton about Javascript engine internals, so...</p>
  
  <p>The reason I ask is because that array, when converted to a string, will have a bunch of undefined's in the middle of it. Are those actually stored in some fashion, or is that just put in at string conversion?</p>