So simple.
var hash = window.location.hash.substr(1)
There are also these two that return the same:
var hash = window.location.hash.slice(1) var hash = window.location.hash.substring(1)
String.slice() was added to the specification a bit later, although this is possibly irrelevant.
The use of a replacement, as indicated below, is also an option.
None of these options give an error or warning if the window.location.hash line window.location.hash empty, so it really depends on your preference for what to use.
MildlySerious
source share