Skip to main content
property URL.hash

The hash property of the URL interface is a string that starts with a # and is followed by the fragment identifier of the URL. It returns an empty string if the URL does not contain a fragment identifier.

Examples

Example 1

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

Example 2

const myURL = new URL('https://example.org');
console.log(myURL.hash);  // Logs ""

Type

string

See

Back to top