Languages
[Edit]
EN

JavaScript - remove suffix from string

0 points
Created by:
Aisha
418

In this article, we would like to show you how to remove suffix from string in JavaScript.

Quick solution:

 

Practical examples

Edit

1. String.prototype.replace() with regex

Edit

In this example, we use replace() method with regex to replace the last two letters (CD) with an empty string.

2. String.prototype.slice()

Edit

In this example, we use slice() method to remove the last two letters from the text.

3. String.prototype.substring()

Edit

In this example, we use substring() method to remove the last two letters from the text.

References

Edit
1
Donate to Dirask
Our content is created by volunteers - like Wikipedia. If you think, the things we do are good, donate us. Thanks!
Join to our subscribers to be up to date with content, news and offers.

JavaScript - String (popular problems)

JavaScript - remove suffix from string
Native Advertising
🚀
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

❤️💻 🙂

Join