Location port property
Definition and Usage
port property is a readable and writable string sets or returns the port portion of the current URL.
Note: If the port number is 80 (which is the default port number), without specifying.
grammar
location.port
Browser Support
All major browsers support port property
Examples
Examples
Returns the port number of the current URL:
<script>
document.write(location.port);
</script>
document.write(location.port);
</script>
Examples of the above output:
try it"
Location Object