Web APIs
URL.hash
Reads or sets the fragment of a URL object. Modifying a detached URL does not navigate the document.
Formal Syntax & Structure
javascript syntaxjavascript
url.hashReturn Value
string
Fragment including #, or empty string.
Working Example
Example Snippetjavascript
(async () => {const u=new URL("https://example.test/guide#part");u.hash="next";console.log(u.hash,u.pathname);})()