Weird error with document.location.hash

I am having a weird error with the document.location.hash property.

I have a function that receives a parameter which is then applied to this property.

If the parameter has the “#” sign applied when the function receives it then it works, but if the “#” sign is concatenated inside the function then it does not work.

This works:


function update(address)
{
	window.location.hash = address;
}
(When address = "#test")

This does not work:


function update(address)
{
	window.location.hash = "#" + address;
}
(When address = "test")

Is there a reason why this is happening ?