JavaScript window location port property enables you to get the port number of the current URL hostname being accessed by the web browser. JavaScript location port porperty returns the port number only the accessed URL is beign accessed by using port number with its host address. JavaScript location object belongs to JavaScript window object that allows you to access the hostname property using window.location.port. You can also access the port property directly as location.port.
Try the sample below to learn and practice the code functionality of JavaScript window location port property: