How can I convert a string to a JavaScript array?
Look at the code:
var string = \"0,1\"; var array = [string]; alert(array[0]);
In
use the built-in map function with an anonymous function, like so:
string.split(',').map(function(n) {return Number(n);});
[edit] here's how you would use it
var string = "0,1"; var array = string.split(',').map(function(n) { return Number(n); }); alert( array[0] );