I have below string -
var a = \"1,2,3,4\";
when I do -
var b = a.split(\',\');
I get b
as
You can transform array of strings to array of numbers in one line:
const arrayOfNumbers = arrayOfStrings.map(e => +e);
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])
One liner
Array.from(a.split(','), Number)