JavaScript: Quickly Trim the Last Character from a String

When developing web applications, you undoubtedly have wanted to remove the last character from a string (such as a URL or application path)  in your JavaScript code.

Here’s a quick way to get it done using the JavaScript function slice():

 
var applicationPath = '/my/application/path/';
var removedLastCharacter = applicationPath.slice(0, -1);
This entry was posted in JavaScript. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *