📜  javascript代码示例中的修剪逗号

📅  最后修改于: 2022-03-11 15:03:11.498000             🧑  作者: Mango

代码示例1
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(/,$/, "");