Example: Get The Current URL
// program to get the URL
const url_first = window.location.href;
const url_second = document.URL;
In the above program, window.location.href property and document.URL property are used to get the URL of the current page.
Both the window.location.href and the document.URL properties return the URL of the current page.