I have below string -
var a = \"1,2,3,4\";
when I do -
var b = a.split(\',\');
I get b as
b
You can use JSON.parse, adding brakets to format Array
const a = "1,2,3,4"; const myArray = JSON.parse(`[${a}]`) console.log(myArray) console.info('pos 2 = ', myArray[2])