Sometimes, we want to remove the string on the beginning of an URL with JavaScript.
In this article, we’ll look at how to remove the string on the beginning of an URL with JavaScript.
How to remove the string on the beginning of an URL with JavaScript?
To remove the string on the beginning of an URL with JavaScript, we can use the string replace
method.
For instance, we write
const s = "www.testwww.com".replace("www.", "");
to call replace
with 'www.'
and ''
to replace 'www.'
with an empty string to return a string without 'www.'
at the beginning.
Conclusion
To remove the string on the beginning of an URL with JavaScript, we can use the string replace
method.