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
You can use javascript Spread Syntax to convert string to an array. In the solution below, I remove the comma then convert the string to an array.
var string = "0,1" var array = [...string.replace(',', '')] console.log(array[0])