JS Built-ins
URLintermediate

URL Constructor β€” round-trip

πŸ“– Usage Example
const u = new URL('https://example.com:8080/path')
u.port  // β†’ '8080'

URL() extracts the port number when it is specified in the URL.

URL Constructor β€” round-trip

Creating a URL from an existing URL's href should produce the same href.

Challenge: Verify that new URL(url.href).href === url.href.

πŸ’‘ Hints (1)
  • β€’ href is the full serialized URL string