Chrome Extension

Remove last character of a string in Javascript

var str = "Hello World";
var finalStr = str.substring(0, str.length-1);

Do you know, you can create and search your own code snippets on Devsheet. Store your code on cloud using devsheet and search using its chrome extension. Is it look cool?

Hello Worl

To remove the last character from a string in javascript you can use .substring() function of javascript and pass start and end index as a parameter. Here we have passed the start index as 0 and the end index as string length - 1.

Was this helpful?
Never leave your website again in search of code snippets by installing our chrome extension.