var functionExpressionA = function(){
return x+1;
};
var functionExpressionB = function(){
return y+1;
};
var y=10;
var x=20;
functionExpressionB(); //returns 11
functionExpressionA(); //returns 21
I would like to clarify how hoisting and parsing of this code works in the above example.
My understanding is that the variable names var y and var x are hoisted. However, their assignments 10 and 20 are not hoisted.
If the above is true how is this snippet of Javascript actually parsed by the browser?
With specific interest to the function expressions which contain a variable which at the time of parsing (because of hoisting only the variable name) is undefined