title: Remove &quot; when printing an array in the JavaScript console
body: <p>I have an array that I am passing to a javascript file. </p>
  
  <p>In the controller I have the array printing out and it appears like so...</p>
  
  <pre><code>["123456789", "987654321", "147852369", "369852147"]
  </code></pre>
  
  <p>This array is set to the instance variable @array in the controller. </p>
  
  <p>I'm sending this array to a JavaScript file by setting <code>@array</code> as a variable in the view.</p>
  
  <pre><code>var array = "&lt;%= @array %&gt;";
  </code></pre>
  
  <p><em>Note: I've tried <code>var array = "&lt;%=raw @array.to_json %&gt;";</code> as well.</em></p>
  
  <p>Then in the JavaScript file I am simply printing the array in the console like so...</p>
  
  <pre><code>console.log(array);
  </code></pre>
  
  <p>However when it is printed in the console the output looks like this.</p>
  
  <pre><code>[&amp;quot;123456789&amp;quot;, &amp;quot;987654321&amp;quot;, &amp;quot;147852369&amp;quot;, &amp;quot;369852147&amp;quot;]
  </code></pre>
  
  <p>When I check the typeof through jQuery it comes back as a string instead of an array.</p>
  
  <p>I do not want to see the <code>&amp;quot;</code>. Eventually I want to use these values as selectors when running some JavaScript functions.</p>
  
  <p>Through these steps, what am I doing wrong that is producing the <code>&amp;quot;</code>?</p>
  
  <p>edit: This is how I am initially creating my array.</p>
  
  <pre><code>  CONTROLLER
    @original= large_array_of_hashes
    # I am grabbing only specific data from the hash. Only what comes after @errors=&gt;
    @data = @original.scan(/@errors=&gt;"(.*?)"/).flatten.map{ |msg| msg.gsub(/(\.|\s+)/, '').strip }
    @array = []
    @data.each{|data| @array &lt;&lt; data}
  </code></pre>