DEV Community

Discussion on: Understanding Hoisting

Collapse
 
attraverso_dev profile image
attraverso

Thank you for writing this. As you said, there is no one else that I've seen who talks about the different phases of the execution context, and that helped a lot.

One thing, though. I was thrown off by the fruit/color example as the output in the snippet doesn't seem to match the description you give of it. The output in the snippet returns the complete sentences, like the variables fruit and color were actually read, while instead the description says the output will return undefined as value of those same variables.

Am I missing something crucial?

Collapse
 
skaytech profile image
skaytech • Edited

Hello there,

Apologies! My bad on the incorrect output in the code section. I usually code in the editor and ensure the output is valid. But, in this case, I added console.log in the end and wanted to showcase before and after and later changed my script in the main article, but forgot to update it in the code portion of the article.

I have now updated it to reflect the correct output.

I'm surprised how this wasn't brought to my notice earlier. Kudos to you! I'm glad that folks are actually reading my articles. (even the code sections) I'll ensure that I verify the next time I post an article.

Thank you once again. I'm going to extend the concepts and also explain Closures which is another famous interview question as well as something often confused with. Hoping to publish it by end of the day. Stay tuned!

Collapse
 
attraverso_dev profile image
attraverso

Thank you for taking the time to read the comment and review your article! I'll be looking forward to your next posts!