JavaScript window location host property enables you to get the domain name/IP address and Port number of the current URL location of web browser. If the current URL contains domain name it returns the domain name and if URL contains the IP address then host property returns the IP address. JavaScript location host property is a combination of location hostname and location port property. If URL contains port number then location host property returns domain name or IP address along with posrt number e.g.: www.domainname.com:8080. JavaScript location object belongs to JavaScript window object that allows you to access the host property using window.location.host. You can also access the host property directly as location.host.
Try the sample below to learn and practice the code functionality of JavaScript window location host property: