We are going to use the location property in the window object (this.windows.location) which references the global window object
First, let us assign it to a variable.
Assign the const to the window.location
After the declaration, we can now “console.log” the variable to see what we get back.
In the console, something similar to these will be returned back.
In the above-logged window, we can the various properties returned including the host, hostname, href, origin, pathname and the port.
In this case, we only want the current URL we are viewing and it is referenced with the “href ” property.
We can re- assign it using another variable and log out to the console to see the output
Now lets “console.log” the variable to see out the current URL we are currently in.
look the current URL we are in
Look at what we get! amazing right
You can build awesome things with this such as you can append it to buttons are many more.