Access host name
window.location.hostname //Result- mightytechno.com
window.location.protocol //Result- https:
Access full URL
Get path name of URL
Reload current URL
Assign different URL
This will load the new URL
Replace with new URL
Different between assign and replace
Assign and replace handle history in different way. If you use replace the previous URL will not be added to history and you can go back to that URL by clicking back button in browser. If you use assign it will keep previous URL in history and you can go back by browser back button.
Different between host and hostname
Hostname return the name of host only and host return name of the host with port number.
As a example if url is http://example.com:8080
window.location.host //Result - example.com:8080 window.location.hosname //Result - example.com