Javascript/Jquery Convert string to array
<p>i have a string </p>

<pre><code>var traingIds = "${triningIdArray}";  // ${triningIdArray} this value getting from server 
alert(traingIds)  // alerts [1,2]
var type = typeof(traingIds ) 
alert(type)   // // alerts String
</code></pre>

<p>now i want to convert this to array so that i can iterate</p>

<p>i tried </p>

<pre><code>var trainindIdArray = traingIds.split(',');
$.each(trainindIdArray, function(index, value) { 
    alert(index + ': ' + value);   // alerts 0:[1 ,  and  1:2]
});
</code></pre>

<p>how to resolve this?</p>
