by @saigowthamr

How to Remove the Last Character of a String in JavaScript?

Home » javascript » How to Remove the Last Character of a String in JavaScript?

To remove the last character of a string we need to use the slice() method by passing 0,-1 as arguments in JavaScript.

Here is an example that removes the last character o of a string.

const string = "hello";

console.log(string.slice(0,-1)); // "hell"