What is the hoisting difference between var, let, and const?
var is hoisted and initialized to undefined. let and const are hoisted (memory allocated) but kept uninitialized in the Temporal Dead Zone. Accessing them before the declaration line throws a ReferenceError.
Verify This Answer
Cross-check this information using these trusted sources:
More FAQs in var vs let vs const Hoisting in JavaScript
Yes, memory is allocated for them. But they remain in the Temporal Dead Zone until the declaration line is reached. Accessing them early throws a ReferenceError, unlike var which returns undefined.
The period between the start of a block scope and the line where a let or const variable is declared. During this period, accessing the variable throws a ReferenceError.
No. Redeclaring let or const in the same scope throws a SyntaxError. var allows redeclaration silently, which is one reason to avoid var in modern code.
Still have questions?
Browse all our FAQs or reach out to our support team
