JavaScript URL to String | Read-only version of URL href

  • by

Use toString() stringified method to convert URL to String in JavaScript. It will return USVString containing the whole URL read-only version of URL href.

const str_href = url.toString()

JavaScript URL to string Example code

HTML example code: should return the URL as a string.



		var url = new URL("");




JavaScript URL to String

Do comment if you have any doubts and suggestions on this JS URL topic.

Note: The All JS Examples codes are tested on the Firefox browser and the Chrome browser.

OS: Windows 10

Code: HTML 5 Version

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.