JavaScript Location hash Tutorial

In this section, we will learn what Location hash property is and how to use in JavaScript.

JavaScript Location hash Property

Via the `hash` property, we can get or set the URL hash value (the pound `#` sign followed by string characters) of the currently loaded document in a browser window.

Note: if there’s no hash in the URL, the return value of this property will be an empty string.

Location hash Syntax:


Example: using Location hash property in JavaScript

const value = location.hash;


Leave a Reply