Skip to main content
URL.prototype.hash - url - Node documentation
property URL.prototype.hash

Usage in Deno

import { URL } from "node:url";

Gets and sets the fragment portion of the URL.

const myURL = new URL('https://example.org/foo#bar');
console.log(myURL.hash);
// Prints #bar

myURL.hash = 'baz';
console.log(myURL.href);
// Prints https://example.org/foo#baz

Invalid URL characters included in the value assigned to the hash property are percent-encoded. The selection of which characters to percent-encode may vary somewhat from what the parse and format methods would produce.

Type

string