How can I obtain an array from the string "[1, 12, 2, 3, 4]"?
<p>In my JSP, a hidden variable value shows as following.</p>

<pre><code>&lt;input type="hidden" name="" value="[1, 12, 2, 3, 4]" id="rollNumber"/&gt; 
</code></pre>

<p>When I try to get hidden variable in javascript function by <code>document.getElementById</code> and put it in a array (<code>rollNo</code>) as follows:</p>

<pre><code>rollNo = document.getElementById("rollNumber").value; 
</code></pre>

<p><code>rollNo</code> value is coming as <code>[1, 12, 2, 3, 4]</code></p>

<p>When I try to iterate <code>rollNo</code> it gives me elements as:</p>

<pre><code>[
1
,
space
1
2
, 
space  etc... elements
</code></pre>

<p>I need only elements like <code>'1 12 2 3 4'</code></p>
