I have below string -
var a = \"1,2,3,4\";
when I do -
var b = a.split(\',\');
I get b as
b
A more shorter solution: map and pass the arguments to Number:
Number
var a = "1,2,3,4"; var b = a.split(','); console.log(b); var c = b.map(Number); console.log(c);