JS Built-ins
URLbeginner

URL Properties β€” pathname and search

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

hash returns the fragment identifier including the '#' character.

URL Instance Properties β€” pathname & search

pathname is the path portion. search is the query string including ?.

Challenge: Parse 'https://a.com/path/to/page?q=hello&lang=en' and inspect pathname and search.

πŸ’‘ Hints (1)
  • β€’ search includes the leading ? character