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