Open In App

Node.js urlObject.hash API

Improve
Improve
Like Article
Like
Save
Share
Report

Before we go on to learn about URL objects API we need to know a brief about URL.

If you ever wanted to provide utilities so as to parse or resolute your URL, we can do it through the URL Module.

We can divide the URL Module into two parts:- These are- URL String and URL Object. The urlObjectHash is a part of URL Object which is generally based on Legacy API (Though a newer API is also provided by the name of WHATWG URL Standard)

urlObject.hash: It is used for identifying the “fragment” portion of a URL. This property also includes the # character.

For example: '#hash'.

Syntax

urlObject.hash

Example:




const url = require('url');
const reqUrl = 'www.example.com/hi#file?=newFile'
const urlObject = url.parse(reqUrl, true);
  
console.log(urlObject.hash);


OUTPUT:

#file?=newFile

Last Updated : 14 Oct, 2021
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads