Languages
[Edit]
EN

TypeScript - remove suffix from string

0 points
Created by:
Bess
571

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

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.

Output:

2. String.prototype.slice()

Edit

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

Output:

3. String.prototype.substring()

Edit

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

Output:

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.
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