title: Filling javascript array with key + value
body: <p>I'm working on an app that uses an html/javascript framework.
  The app loads in pages from a database using a PHP script and a $.get call whenever a page is shown like so:</p>
  
  <pre><code>    // Set lastTime var for counting the amount of time passed since $.get
      var lastTime = 0;
  
      // Amount of minutes before new $.get
      var timeOut = 1;
  
      // Cache
      var cache = [];
  
      function load_page(page, location) {
          // Check if 1 minute passed
          if ( Math.floor((new Date() - lastTime)/60000) &lt; timeOut ) {
              // Get cache
              $(location+' .homeText').html(cache[page]);
          } else {
              // Get URL
              $.get('http://mydomain.com/get_posts.php?page='+page, function(data) {          
                  $(location+' .homeText').html(data);
              });
  
              // Fill array with data
              cache.push();
  
              // Set lastTime var for checking how long since URL fetch
              lastTime = new Date();
          }
      }
  </code></pre>
  
  <p>It's almost done but I can't figure out how to populate my <code>cache</code> variable.
  I want to populate it in such a way that I can use the <code>page</code> variable as a key to keep everything as dynamic as possible. I know how to fill an array with data but I can't figure out how to give it a specific key and value.</p>