title: Array resets after push
body: <p>I want that when I press the submit button it adds a value to the array but instead it keeps returning the same value.</p>
  
  <pre><code>$(document).ready(function(){
      if(typeof arr == "undefined"){
          var arr = new Array();
      }
  
      arr.push(2);
      $("#submit").click(function(){
         console.log(arr);
      });
  });
  </code></pre>
  
  <p>I want it to add a 2 each time I press submit like this:
  First press</p>
  
  <pre><code>[2]
  </code></pre>
  
  <p>Second press</p>
  
  <pre><code>[2, 2]
  </code></pre>
  
  <p>But now the array just stays 2 as if it just refreshes.</p>