At what stage is the memory allocated to variables in JavaScript with respect to declaration and initialization?
console.log(a); // Prints undefined
var a;
a = 20;
For the above snippet, a = undefined even before the code execution starts. Does that imply that memory has been allocated during the creation of the variable environment with no value (undefined)? If yes, during code execution phase when the JavaScript engine comes across a = 20 does a new memory block gets allocated to 20 to which a points?