Docs

URL.prototype.hash

The fragment identifier of the URL (includes the #).

Example

let url = new URL("https://example.com/path#section")
url.hash
"#section"
let url = new URL("https://example.com")
url.hash = "#top"
url.href
"https://example.com#top"