var keyword) before assign it any value, we get
undefined. But that's not the case with variables defined using
const. If we try to access a variable (declared using
const) before assigning it any value, we get
Many people believe the reason behind this behavior is that
const are not hoisted, which is not true. Just like
var, they are hoisted, but what they lack is the initialization process which
var goes through but
const do not.
const, initialization is only complete when a value is assigned to the variable; and the period from start of the block scope to initialization of value, where we receive
ReferenceError, is known as the Temporal Dead Zone.
Wrapping up: All
const are hoisted. But, unlike
const do not go though initialization process. The time (zone) from start of block scope to actual initialization is called Temporal Dead Zone 🐱👤.