Remove Last Character from String in JavaScript

Best Solution: How do I remove last character from a string in JavaScript, jQuery or Node.js, angularjs, vuejs script?

Remove Last Character From String JavaScript

This tutorial describes simple Three JavaScript string methods to remove last character from a string in JavaScript client side programming language. You can simply use any one of the following JavaScript string methods as per the user need.

  • JavaScript String substring() Method
  • JavaScript String slice() method
  • JavaScript String substr() method
  • javascript trim last character
4 Methods to delete first and Last Characters from String in Java Script
remove last character from string java-script

Method 1 – Using JavaScript substring function

JavaScript String substring() Method

Use the substring() string function to remove the last character from a string in Java Script source code. This javascriptstring function simple returns the section of the string between the start and end indexes, or to the get the data string end of the string.


str.substring(0, str.length - 1);

Example :

var removeLastCharacter= "Hello FontSpace Toopics!";
var newStr = str.substring(0, removeLastCharacter.length - 1);
java script remove character from string, javascript remove last character of string, javascript remove part of string, string remove last character, java remove last character from string, get last character of string javascript, java string remove last character, how to remove last character from string, remove part of string javascript
JavaScript substring function

Method 2 – Using JavaScript slice function

JavaScript String slice() method

Use the slice function to remove the last character from any users string in Pure JavaScript functions. This js remove last character function extracts a section of any string as well as return as fresh data string. When you can save or included in a variable like as below example.


str.slice(0, -1);


var removeLastCharacter = "Hello FontSpace Toopics!";
var newStr = removeLastCharacter.slice(0, -1);
javascript remove substring, remove last letter from string javascript, javascript get last character of string, js string remove last character, javascript strip last character, remove the last character from a string, remove character from string javascript, delete last character in string, javascript remove substring from string
JavaScript slice function

Method 3 – Using JavaScript substr function

JavaScript String substr() method

Use the slice method returns a here portion of the users data string, starting points at the specified point of the index as well as extract specified number of characters. The substr() method is match a legacy Pure Javascript function as well as substring() method need to used instead. When you can save or included in a variable like as below example.


str.substr(0, -1);


var removeLastCharacter = 'Jaydeep';

removeLastCharacter = removeLastCharacter.substr(0, removeLastCharacter.length - 1);

	Output: Jaydee

javascript remove characters from string, string delete last character, remove characters from string javascript, js remove character from string, remove last character, javascript last character of string, javascript remove first and last character, string remove last character javascript, javascript strip characters
JavaScript substr function

JavaScript Example: String.substr()

const removeLastCharacter = 'Jaydeep';

console.log(removeLastCharacter.substr(1, 2));
// expected results: "ay"

// expected results: "ydeep"

javascript trim last character

JavaScript String trim() Method

Note: The Javascript trim() function is not supported old Browsers in Internet Explorer 8 as well as older or earlier can simple Click the HTML button to alert Javascript box the string with removed all the whitespace.

Web Programming Tutorials Example with Demo

Read :


You can also read about AngularJS, ASP.NET, VueJs, PHP.

I hope you get an idea about using Javascript String Properties and Methods.
I would like to have feedback on my blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.

Leave a Comment