below are one of the examples that you can seprated by comma each element and also remove empty elements
var p = ",32111_10589,32111_10591,32111_10593,32111_10613,32111_10590,32111_10592,32111_10594,32111_10614,32111_10595,32111_10593_5673,32111_10593_5674,32111_10590_5651,32111_10592_5669,32111_10594_5671,32111_10614_5687,32111_10590_5652,32111_10592_5670,32111_10594_5672,32111_10614_5688,32111_10595_5675,32111_10595_5676,";
// remove first and last element from array and seprated elements by comma.
var ar = p.slice(1,-1).split(',');
First you can split with , and the using filter to filter out the empty string
You might wonder what exactly is .filter(s => s). It filter out the empty string because "" is considered as falsy value.
If s is empty string then it is filtered out else included in the final result.
var p =
",32111_10589,32111_10591,32111_10593,32111_10613,32111_10590,32111_10592,32111_10594,32111_10614,32111_10595,32111_10593_5673,32111_10593_5674,32111_10590_5651,32111_10592_5669,32111_10594_5671,32111_10614_5687,32111_10590_5652,32111_10592_5670,32111_10594_5672,32111_10614_5688,32111_10595_5675,32111_10595_5676,";
var arr = p.split(",").filter(s => s);
console.log(arr);
But there is a case that won't cover is if there is a empty space in between , then you can use trim
var p = " ,32111, ";
var arr = p.split(",").filter(s => s.trim());
console.log(arr);