Skip to main content
property URL.host

The host property of the URL interface is a string that includes the URL.hostname and the URL.port if one is specified in the URL includes by including a : followed by the port number.

Examples

Example 1

const myURL = new URL('https://example.org/foo');
console.log(myURL.host);  // Logs "example.org"

Example 2

const myURL = new URL('https://example.org:8080/foo');
console.log(myURL.host);  // Logs "example.org:8080"

Type

string

See

Back to top