JS Built-ins
URLbeginner

URL Properties β€” hostname, port, host

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

pathname returns the path portion of the URL.

URL Instance Properties β€” hostname, port, host

hostname is the domain without port. port is the port string (empty if default). host is hostname + port.

Challenge: Parse 'http://host.com:8080/p' and check these properties.

πŸ’‘ Hints (1)
  • β€’ port is empty string when using the default port for the protocol