An execution context has 2 phases:
– Creation phase
– Execution phase
‘Let’ is processed in the Execution Phase.
Thus, unlike var, which is parsed and kept in memory in the Creation phase, let is processed in the Execution Phase and cannot be hoisted. This means the let variable will be visible inside the block which it was created. Like any other declared variables, it is also kept in memory.
1 2 3 4 5 |
{ let c = 10; // c is visible in this block only. // also called block scoping } |