#1 – href
This will return the entire URL displaying in the address bar.
var currentURL = window.location.href;
#2 – host
This will return the hostname and port of the URL in the address bar.
var currentHost = window.location.host;
#3 – hostname
This will return only the hostname of the URL in the address bar.
var currentHostname = window.location.hostname;
#4 – port
This will return only the port detail of the URL in the address bar.
var currentPort = window.location.port;
#5 – protocol
This will return the protocol of the URL in the address bar. Like the URL is using HTTP (without SSL) or HTTPS (with SSL).
var currentProtocol = window.location.protocol;
#6 – pathname
This will return the pathname (value after the domain name) of the URL in the address bar.
var currentPathname = window.location.pathname;
#7 – hash
This will return the anchor portion of the URL including hash sign (#).
var currenthash = window.location.hash;
#8 – search
This will return the query portion of the URL like portion started with the question mark (?).
var currentSearchString = window.location.search;