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
More "Try it Yourself" examples below.
Definition and Usage The split() method is used to split a string into an array of substrings, and returns the new array.
Tip: If an empty string ("") is used as the separator, the string is split between each character.
Note: The split() method does not change the original string.
var res = str.split(",");