remove all commas at the end of a string javascript code example Example: remove last comma from string javascript str = str.replace(/,\s*$/, "");