Categories
JavaScript Answers

How to remove the string on the beginning of an URL with JavaScript?

Spread the love

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.

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published. Required fields are marked *