my corner

Temporal Dead Zone

August 10, 2020

I got a question on the last job interview what is the Temporal Dead Zone. I have not heard about this concept before and as you can guess I did not know the answer. This gave me an idea to write this post about the concept. This post will be short and sweet. Let’s get to the point.

What is temporal dead zone

When you are working with var keyword it will be hoisted and initialized with the undefined value. let and const are also hoisted but they do not get an initial value. Let’s see the example:

console.log(varTest) //undefined
var varTest
console.log(letTest) //ReferenceError: letTest is not defined
let letTest

Maybe this was not the best example but it serves a purpose.

Conclusion

That is the Temporal Dead Zone. Nothing spectacular but now if you hear that term somewhere you will know what is it about.

If you have some thoughts to share or I missed something feel free to comment.


Personal blog by Alen Šljivar who is trying to write something meaningful.