Even let and const are hoisted (meaning, the engine does store them in memory, as seen in this gif), they just don’t get initialized with the default value of undefined 😃
Is this why a Reference Error is thrown? Because the JS engine knows not to use the global 'randomValue' variable? I.e., JS knows that the variable 'randomValue' is within the current block scope and thus the value of this locally-scoped 'randomValue' should be the preferred variable. So, although JS is aware of this local variable (because of hoisting) nonetheless the reference error is thrown because the variable cannot be referenced prior to being initialized (since we're using const here). Am I right about this?
btw.. ABSOLUTELY loving EVERYTHING you've done. From articles, your personal site, just amazing content all around. Thanks so much for all this amazing material!
I signed up to dev.to just to like your articles haha.
Keep up the great work!
avocados
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Even let and const are hoisted (meaning, the engine does store them in memory, as seen in this gif), they just don’t get initialized with the default value of undefined 😃
Is this why a Reference Error is thrown? Because the JS engine knows not to use the global 'randomValue' variable? I.e., JS knows that the variable 'randomValue' is within the current block scope and thus the value of this locally-scoped 'randomValue' should be the preferred variable. So, although JS is aware of this local variable (because of hoisting) nonetheless the reference error is thrown because the variable cannot be referenced prior to being initialized (since we're using const here). Am I right about this?
btw.. ABSOLUTELY loving EVERYTHING you've done. From articles, your personal site, just amazing content all around. Thanks so much for all this amazing material!
I signed up to dev.to just to like your articles haha.
Keep up the great work!
avocados