Sometimes, we want to remove part of a string with JavaScript.
In this article, we’ll look at how to remove part of a string with JavaScript.
How to remove part of a string with JavaScript?
To remove part of a string with JavaScript, we call the string substring
method.
For instance, we write
const str = "test_23";
alert(str.substring("test_".length));
to call str.substring
with the starting index of the str
string to return.
Then the alert box should show '23'
.
Conclusion
To remove part of a string with JavaScript, we call the string substring
method.