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
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.
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.