Javascript check for hash in URL

JavaScript
if (location.href.indexOf("#") != -1) {
    //current url has a #hash in it
}
Source

Also in JavaScript: