What does the hash return?

-2

I have not found, what thing returns if I do:

if (window.location.hash = '')

Being the web http://eduard.com

    
asked by Eduardo Sebastian 10.05.2017 в 19:55
source

1 answer

2

You should not return anything with that URL , the hash as its name indicates it gets the # and what is after this

Ejm

http://eduard.com  // retorna vacío 
http://eduard.com#hola  // retorna #hola

The value that returns if there is no hash will be an empty string , a way to check the return value would be

var x = window.location.hash;
console.log(typeof x);  // return string

Another thing to keep in mind is that in if the comparison would be with == , that is

if (window.location.hash == ''){... //Sin Hash}
    
answered by 10.05.2017 / 20:02
source