1. slice()
const str = "Hello, World, JavaScript,"; let newStr = str.slice(0, -1); console.log(newStr); newStr = str.slice(0, str.length - 1); console.log(newStr);
2. substring()
const str = "Hello, World, JavaScript,"; const newStr = str.substring(0, str.length - 1); console.log(newStr);
3. substr()
const str = "Hello, World, JavaScript,"; const newStr = str.substr(0, str.length - 1); console.log(newStr);
4. replace()와 정규표현식
const str = "Hello, World, JavaScript,"; const newStr = str.replace(/,$/, ''); console.log(newStr);