title: Change array size by just adding element and no push javascript
body: <p>I know the universal way of changing an array's size is to use <code>.push()</code>.</p>
  
  <p>However, today I saw a piece of code in angularJS that does something like this:</p>
  
  <pre><code>var service = {
     pages: [],
     doSmth: doSmth
  };
  
  doSmth();
  
  function doSmth() {
     service.pages[1] = "abc";
     service.pages[5] = "def";
  }
  </code></pre>
  
  <p>I ran the debugger on the browser and found that before <code>doSmth()</code> is called, <code>pages[1]</code> is undefined, but after that, <code>pages[1]</code> is assigned the value without any error.</p>
  
  <p>How is this possible?</p>