Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

trim comma in javascript

let myString = "string,with,trailing,comma,";

// remove the last character of the string (regardless of what it is)
myString.substr(0, myString.length-1)

// remove only a comma if it appears at the end of the string
myString.replace(/,$/, "");
 
PREVIOUS NEXT
Tagged: #trim #comma #javascript
ADD COMMENT
Topic
Name
2+5 =