how to remove last comma in a string using javascript code example Example: remove last comma from string javascript str = str.replace(/,\s*$/, "");