Constructs a new URL.
new URL(url, base?)
url
A string representing an absolute or relative URL.
base optional
A string representing the base URL to use if url is relative.
let url = new URL("https://example.com/path?query=value#fragment")
url.hostname
"example.com"
// Relative URL with base
let url = new URL("/api/data", "https://api.example.com")
url.href
"https://api.example.com/api/data"