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
Another option using the ES6 is using Spread syntax.
var convertedArray = [..."01234"];
var stringToConvert = "012"; var convertedArray = [...stringToConvert]; console.log(convertedArray);