Location port Property
Location object
Definition and Usage
The port property is a readable and writable string that sets or returns the port part of the current URL.
**Note:** If the port number is 80 (which is the default port number), it does not need to be specified.
Syntax
location.port
Browser support





All major browsers support the port property.
Example
Example
Return the port number of the current URL:
The output of the above example is:
Try it »
Location object