Both above code syntax returns the same value from hash "#" sign in the current URL.
To set the bookmark hash value using location hash property you can use the following syntax:
location.hash = "#Value";
Use "#" hash sign with value to target the named anchor tag.
location.hash = "#bottom";
Above example shows the use of location.hash property. First anchor <a> tag targets the anchor tag with name="bottom" that adds the "#bottom" to the end of the current URL. Similarly second link targets the anchor tag with name="top" that adds the "#top" to the end of the current URL. You can get the location.hash result as "#top" or "#bottom" according to the value added at the end of current URL. setLocationHash function will change the value from "#" hash sign in the current URL.