Temporal Dead Zone : The let and const variables are not accessible before they are initialized with some value, and the phase between the starting of the execution of block in which the let or const variable is declared till that variable is being initialized is called Temporal Dead Zone for the variable.

Ex :1
console.log(x);
var x = 6;
console.log(x);

Explanation:
First of all the Global execution context will be created.
And then the memory allocation phase starts, During this, the variable x got a place in memory and javascript puts undefined there.
And then the thread execution phase starts, During this console.log(x) statement executes and prints the value store in x, which is undefined.
In the next line, there is x assigned to 6, and the undefined value of x gets replaced by 6.
Again at the next console.log(x), x gets printed as 6.


Ex :2
console.log(x);
console.log(z);
var x = 6;
let z = 6;
console.log(x);
console.log(z);

Explanation:

First of all the Global execution context will be created.
And then the memory allocation phase starts, During this, the variable x got a place in memory and javascript puts undefined there.
And then the variable z gets space in a different place of memory and same as variable x then undefined will be assigned as value.
Then the thread execution phase starts, During this console.log(x) statement executes and prints the value of x, which is undefined.
In the next line, there is console.log(z), javascript will throw ReferenceError and the program will stop here.