title: Javascript How to not to use global variables when creating arrays to access from different functions
body: <p>I read some data with Papa Parse, and I callback the result to <code>unpack</code>. I want to be able to use the created arrays in other functions. (something like <code>console.log(unpack(data))</code> outside <code>unpack</code>.</p>
  
  <p>How do I call the arrays?</p>
  
  <pre><code>//read data from csv 
  function parseData(file, callback) {
      Papa.parse(file, {
          download: true,
          complete: function(results) {           
              callback(results.data);
          }
      });
  }
  
  // want to use the created arrays in other functions.
  function unpack(data) {
      var locations = [];
      var bsis = [];
      var lngs = [];
      var lats = [];
  
      for (var i = 0; i &lt; data.length; i++) {
          locations.push(data[i][2]);
          bsis.push(data[i][3]);
          lats.push(data[i][4]);
          lngs.push(data[i][5]);
      }
      return [locations, bsis, lats, lngs];
  }
  </code></pre>
  
  <p>I call it with</p>
  
  <pre><code>parseData("data/Runs/csvs/csvs_with_latlon/ShelterRun1.csv", unpack);
  </code></pre>