Skip to content
Related Articles
Open in App
Not now

Related Articles

Node.js urlObject.hash API

Improve Article
Save Article
  • Last Updated : 14 Oct, 2021
Improve Article
Save Article

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
My Personal Notes arrow_drop_up
Related Articles

Start Your Coding Journey Now!