consider these slightly two different versions of hoisting...
mylocation = \"dublin\"
function outputPosition() {
alert(mylocation);
mylocation = \"fing
In the second option, you hide mylocation (which I hope was declared in outer scope.) with a new variable via the var declaration.
"In JavaScript, variable can be declared after being used." meaning: JavaScript pulls up var declarations to the top of the scope(No matter where it was declared!), so in your second function var mylocation is implicitly defined but not assigned before the first alert, hence it output undefined at that point.