Hoisting is one of those fundamental JavaScript concepts that can really throw you for a loop if you don't understand it.
This hopefully clarifies how it works!
Part of the 'What the Fork' series where I illustrate essential dev topics.
#JS #JavaScript #whatthefork
Conversation
Wow, I learned a new thing about hoisting today. Great work on the illustration! 🎨🖌️
2
Incredible - if you sold these as posters on egghead I would buy them.
2
5
that does not look right though. It says "all declarations are hoisted ... we can use .. a variable before we declare it ... as long as we assign it above where we need to use it". It wouldn't work with `let` due to tdz (and makes no sense for `const` at all).
2
1
it even shows exactly that example with `let` (in the bottom left corner) which would throw an exception
1
Show replies
When using `let`, `const` and `class` JavaScript will use block scoping instead of function scoping. And will no longer do hoisting. Instead of an `undefined` value it will give a reference error (behaviour that some people call the Temporal Dead Zone: jsrocks.org/2015/01/tempor)







