For example, I have a URL as :
http://www.google.com/#hash=value2x
I want a js code to return just value2x. I tried
value2x
The URLSearchParams class can be reused for this purpose.
var urlParams = new URLSearchParams(window.location.hash.replace("#","?")); var hash = urlParams.get('hash');