Related Articles

Related Articles

Node | urlObject.hash API
  • Last Updated : 29 May, 2019

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:

filter_none

edit
close

play_arrow

link
brightness_4
code

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

chevron_right


OUTPUT:

#file?=newFile
My Personal Notes arrow_drop_up
Recommended Articles
Page :