title: How can I import a variable from another JavaScript file?
body: <p>I want to import an array (<code>imageArray[]</code>) that is being populated by another JavaScript file (<code>imageUploadDisplay.js</code>) into another JavaScript file function (<code>postInfoAndImages.js</code>). Below is my <code>imageUploadDisplay.js</code> function that I tried to use.</p>
  <pre><code>// In my imageUploadDisplay.js
  
  var imageList = [];
  
  function myImageList() {
  
      return imageList;
  }
  </code></pre>
  <p>As explained by others I use the following jQuery to import <code>imageUploadDisplay.js</code> into the JavaScript <code>postInfoAndImages.js</code>:</p>
  <pre><code>// In my postInfoAndImages.js
  var imageList = [];
  
  $.getScript('imageUploadDisplay.js', function () {
              // Script is now loaded and executed.
              alert(&quot;Script loaded, but not necessarily executed.&quot;);
              imageList = myImageList(); // Picture array
              console(imageList);
          });
  </code></pre>