Locationinterface that is exposed by the global
Windowobject by your browser.
And you can access the
And since Window is a global object in the browser, you can access it using this also:
And if you want the
hrefof the current page, use this:
There are also a ton of other useful properties in the location object.
Here are some examples for the page you are currently on:
location.protocol // "https:"
location.host // "coderrocketfuel.com"
location.hostname // "coderrocketfuel.com"
location.port // ""
location.origin // "https://coderrocketfuel.com"
As always, thanks for reading and happy coding!