The urlObject.port() method in Node is used to get the numeric port portion of the host component within the hostname.
The URL’s port number is returned otherwise None if the port number is not present in the URL.
Syntax : urlObject.port() Return : Returns the URL’s port number or None
Example #1 : In these examples, we have shown how the urlObject.port() method is able to extract the url’s port number from the hostname.
Example #2 :