title: Use Javascript to access a variable passed through Twig
body: <p>I have a controller that passes an array to a twig template, which I want to use in a script written on that page.  How would I go about doing that?</p>
  
  <p>I've tried this in my .twig template:</p>
  
  <pre><code>&lt;script&gt;
      $(document).ready(function(){
          var test = {{ testArray }};
  });
  &lt;/script&gt;
  </code></pre>
  
  <p>but that only works if it's a string.</p>