consider these slightly two different versions of hoisting...
mylocation = "dublin"
function outputPosition() {
alert(mylocation);
mylocation = "fingal" ;
alert(mylocation);
}
outputPosition();
This will output "fingal" and then "fingal"
mylocation = "dublin"
function outputPosition() {
alert(mylocation);
var mylocation = "fingal" ;
alert(mylocation);
}
outputPosition();
This will output "undefined" and "fingal"
Why?