I just don't understand the reason behind hoisting.
var a = 10;
function test() {
alert(a);
var a = 20;
}
I am getting undefined as the value of a due to JavaScript hoisting. Any specific reason behind putting all the declaration at the top.