/* Hoisting exampe - let */
let a = 100;
{
console.log(a); // 100
}
{
console.log(a); // ReferenceError: a is not defined
let a = 50;
}
/* Hoisting took place in {}. */
{
let a=100;
console.log(a); // 100
}
console.log(a); // ReferenceError: a is not defined
First, I know that let andconst have a block scope.
Compilation happens in Execution context units, and hoisting occurs when LexicalEnvironment is created.
And the execution context is created by the execution of global, function, eval code.
Shouldn't hoisting of const andlet be done in global, function, eval code units?
(It seems that hoisting doesn't seem to happen, but this is purely thanks to the help of TDZ. Internally both const and let hoisting.)
If engine meet block {/* code */} (rather than function) while creating Execution Context, are engine adding a new scope for the block to [[Scope]]?
