2 Methods to Remove Last Character from String in JavaScript
Question: How do I remove last character from a string in JavaScript or Node.js script?
This tutorial describes 2 methods to remove last character from a string in JavaScript programming language. You can use any one of the following methods as per the requirements.
![javascript remove last character](https://www.pakainfo.com/wp-content/uploads/2020/05/javascript-remove-last-character.png)
Use the substring() function to remove the last character from a string in JavaScript. This function returns the part of the string between the start and end indexes, or to the end of the string.
Syntax:
Example:
Method 2 – slice function
Use the slice function to remove the last character from any string in JavaScript. This function extracts a part of any string and return as new string. When you can store in a variable.
Syntax:
Example:
2 Methods to Remove Last Character from String in JavaScript
Reviewed by Pakainfo
on
May 13, 2020
Rating:
No comments: