diff --git a/doc/api/url.md b/doc/api/url.md index 49dcfbb418bb4f..a890c1696d1645 100644 --- a/doc/api/url.md +++ b/doc/api/url.md @@ -208,9 +208,15 @@ const myURL = new URL('https://example.org:81/foo'); console.log(myURL.hostname); // Prints example.org +// Setting the hostname does not change the port myURL.hostname = 'example.com:82'; console.log(myURL.href); // Prints https://example.com:81/foo + +// Use, myURL.host to change the hostname and port +myURL.host = 'example.org:82'; +console.log(myURL.href); +// Prints https://example.org:82/foo ``` Invalid host name values assigned to the `hostname` property are ignored.