I've a gallery within a website and each gallery image is represented by a url like so:
http://www.example.com/gallery/my-photos#10
http://www.example.com/gallery/my-photos#11
http://www.example.com/gallery/my-photos#12
. . . . .
I've created a conditional statement to prevent user from invalid url.
var galleryNum = window.location.hash.substring(1);
if( typeof(galleryNum) == "string" || typeof(galleryNum) == "NaN" ){
console.log('this is not a number');
}else if(typeof(galleryNum) == "number"){
console.log('this is a number');
}
However this doesn't work, the value I get from window.location.hash.substring(1) will always be a string regardless I enter number or a string.