Node | urlObject.hash API

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

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.




Article Tags :

Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.