title: Javascript: push array onto array with for loop
body: <p>Please explain this to me.  I'm trying to create an array of arrays with a for loop.  When it didn't work, I tried simplifying the code to understand what Javascript is doing, but the simple code doesn't make sense either.</p>
  
  <pre><code>function test(){
      var sub_array = [];
      var super_array =[];
      for (var i=1;i&lt;=3;i++){
          sub_array.push(i);
          super_array.push(sub_array);
      }
      alert(super_array);
  }
  </code></pre>
  
  <p>I expect to see [1; 1,2; 1,2,3].
  Instead I get [1,2,3; 1,2,3; 1,2,3].
  I get the same phenomenon if I loop 0-2 and assign by index.</p>