DEV Community

Discussion on: πŸ”₯πŸ•ΊπŸΌ JavaScript Visualized: Hoisting

Collapse
 
islamhanafi94 profile image
Islam Hanafi Mahmoud

First things first, thank you Lydia for this amazing topic. and I've a question regarding using let.

I think let variables is initialized to with undefined. but due to being in temporal zone it's value is inaccessible.

I tried

let x;
console.log(x); // resulting >> undefind

Collapse
 
swasdev4511 profile image
Swastik Upadhye

Yes this is true... The value will be accessible only after the temp dead zone expires...

Collapse
 
fahim04blue profile image
Shahriar Saleh Fahim

It results undefined because you have initialized the variable 'x' already but haven't defined the variable with any value. This is why it prints out undefined.