title: JavaScript: Accessing Variables Defined in External .js Files
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/10864701/dynamically-importing-javasscript">Dynamically Importing JavasScript</a>  </p>
  </blockquote>
  
  
  
  <p>Is there a way to access variables which come from external imported JavaScript .js files?</p>
  
  <p>In the external .js file I define a varialbe such as follows:</p>
  
  <pre><code>// JavaScript Document
  var PETNAME = "Beauty";
  </code></pre>
  
  <p>After dynamically importing that code, I wish to access PETNAME variable, but I do not get the defined value:</p>
  
  <pre><code>alert("Pet Name: " + PETNAME);
  </code></pre>
  
  <p>What can be wrong, and is there a way to bring values from external .js code into the master JavaScript?</p>
  
  <p>Thank you.</p>