Both location and location.href are used to set or return the complete URL of your current page. They return a string which contains the entire URL with the protocol.
location = "https://www.geeksforgeeks.org";
location.href = "https://www.geeksforgeeks.org";
Commands like location.split(“#); cannot be used as location is an object but location.href can be used as it is a string.
Example: The following code demonstrates the DOM Location href property.
Before Clicking the Button:
After Double Click on Button: