1var stringWithCommas = 'a,b,c,d';
2var stringWithoutCommas = stringWithCommas.replace(/,/g, '');
3console.log(stringWithoutCommas);
1var purpose = "I, Just, want, a, quick, answer!";
2
3// Removing the first occurrence of a comma
4var result = purpose.replace(",", "");
5
6// Removing all the commas
7var result = purpose.replace(/,/g, "");
1/[,\s]+|[,\s]+/g
2
3var str= "your string here";
4//this will be new string after replace
5str = str.replace(/[,\s]+|[,\s]+/g, 'your string here');
6