title: How do I access a variable in HTML document form external JavaScript file
body: <p>If I have a variable in the <code>&lt;script&gt;</code> tags of an HTML document; lets call it <code>example</code>.</p>
  
  <p>How can I access <code>example</code> in my JavaScript file?</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;!DOCTYPE html&gt;
  &lt;head&gt;
   &lt;link rel="stylesheet" type="text/css" href="css/example.css"&gt;
   &lt;link rel="icon" href="https://www.example.com/icon.png"&gt;
   &lt;title&gt;Exsample&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
   &lt;script&gt;
    var example = "example"
   &lt;/script&gt;
  &lt;/body&gt;</code></pre>
  </div>
  </div>
  </p>