DEV Community

Discussion on: Differences between "var" and "let" keywords?

Collapse
 
kendyl93 profile image
Paweł • Edited

We can read in MDN that let and const are actually hoisted.

,,In ECMAScript 2015, let and const are hoisted but not initialized. Referencing the variable in the block > before the variable declaration results in a ReferenceError because the variable is in a "temporal dead zone" from the start of the block until the declaration is processed."

Furthermore in ecma-international it is writtten that:

,,let and const declarations define variables that are scoped to the running execution context's LexicalEnvironment. The variables are created when their containing Lexical Environment is instantiated but may not be accessed in any way until the variable's LexicalBinding is evaluated."

Collapse
 
nunocpnp profile image
Nuno Pereira

True, but in the article I'm talking about var and let .

Collapse
 
kendyl93 profile image
Paweł • Edited

I understand :) but personally I cannot agree with this sentence

,,[...]while variables defined with "let" don't get hoisted."_

However I like your series of a small posts. Keep going ! :)