Skip to main content
Version: 3.13.0

URL.port

The port property of the URL interface is a string containing the port number of the URL.

Note: If an input string passed to the URL() constructor doesn't contain an explicit port number (e.g., https://localhost) or contains a port number that's the default port number corresponding to the protocol part of the input string (e.g., https://localhost:443), then in the URL object the constructor returns, the value of the port property will be the empty string: ''.

Value

A string.