window.location.hash = ‘sourcecodemart’;
2. window.location.host or window.location.hostname
location.host is used to get current domain name.
var a = window.location.host;
location.href is used to get whole current url. Additionaly you can also redirect user to another page.
var a = window.location.href;
window.location.href = “http://google.com”;
location.pathname is used to get current page that you are using.
var a = window.location.pathname;
location.search is used to get url query string.
var a = window.location.search;
location.protocol is to get url protocol like http: or https:.
var a = window.location.protocol;
location.reload() function is used to reload current page.
location.replace function is used to redirect user to another location.
Here I explained very brief introduction about window.location object. If I missed anything then please comment below.