Skip to content

Commit

Permalink
Update examples in “URL: port” doc (mdn#28238)
Browse files Browse the repository at this point in the history
  • Loading branch information
raro42 authored Jul 28, 2023
1 parent bcf5e95 commit 6359ece
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions files/en-us/web/api/url/port/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,18 @@ A string.
## Examples

```js
const url = new URL("https://example.com:80/svn/Repos/");
console.log(url.port); // Logs '80'
// https protocol with non-default port number
new URL("https://example.com:5443/svn/Repos/").port; // '5443'
// http protocol with non-default port number
new URL("http://example.com:8080/svn/Repos/").port; // '8080'
// https protocol with default port number
new URL("https://example.com:443/svn/Repos/").port; // '' (empty string)
// http protocol with default port nubmer
new URL("http://example.com:80/svn/Repos/").port; // '' (empty string)
// https protocol with no explicit port number
new URL("https://example.com/svn/Repos/").port; // '' (empty string)
// http protocol with no explicit port number
new URL("https://example.com/svn/Repos/").port; // '' (empty string)
```

## Specifications
Expand Down

0 comments on commit 6359ece

Please sign in to comment.