title: Pass variables to JavaScript in ExpressJS
body: <p>I am completely lost on this; I am using NodeJS to fetch a JSON and I need to pass the variable to my page and have JavaScript use the data.</p>
  
  <pre><code>app.get('/test', function(req, res) {
      res.render('testPage', {
          myVar: 'My Data'
      });
  </code></pre>
  
  <p>That is my Express code (very simple for testing purposes); now using EJS I want to gather this data which I know to render on the page is simply</p>
  
  <pre><code>&lt;%= myVar %&gt;
  </code></pre>
  
  <p>But I need to be able to gather this data in JavaScript (if possible within a .js file) but for now just to display the variable in an Alert box I have tried</p>
  
  <p>In Jade it is like <code>alert('!{myVar}')</code> or <code>!{JSON.stringify(myVar)}</code>. Can I do something similar in EJS. I don't need any field like <code>&lt;input type=hidden&gt;</code> and taking the value of the field in javascript. If anyone can help be much appreciated</p>