title: Loop through JSON in EJS
body: <p>I have codes in EJS below,</p>
  
  <pre><code>&lt;script&gt;
      var row =&lt;%-JSON.stringify(data)%&gt;
      console.log(row);
  &lt;/script&gt;
  &lt;% for(var i=0; i&lt;JSON.stringify(data).length; i++) {%&gt;
     &lt;tr&gt;
       &lt;td&gt;
         &lt;%= JSON.stringify(data)[i].id%&gt;
       &lt;/td&gt;
     &lt;/tr&gt;
  &lt;% } %&gt;
  </code></pre>
  
  <p>output of row is correct, an array of 3 objects, each with properties id, name etc.. I can manipulate the row to popuate the table in JS. However, I am wonderring whether there is a way to allow it be done in the above manner?</p>
  
  <p>When I run the code above, JSON.stringify(data).length is not 3, but rather the length of the whole string.  </p>
  
  <p>Another questions is when I try to add </p>
  
  <p>&lt;% alert('t'); %> or &lt;% window.alert('t'); %>, it gives me 'not defined' error...</p>
  
  <p>Helps appreciated.</p>
  
  <p>Regards
  Hammer</p>