When should you use const vs let vs var in JavaScript?
Use const by default (most variables should not be reassigned). Use let when you need to reassign (counters, changing loop variables). Avoid var in modern code; it is function-scoped and hoisted with undefined, which causes bugs.
Verify This Answer
Cross-check this information using these trusted sources:
More FAQs in let and const in JavaScript: A Complete Guide
let allows reassignment; const does not. Both are block-scoped and in the TDZ until their declaration line. const must be initialized at declaration; let can be declared without a value (it gets undefined).
No. const prevents reassignment of the variable, but you can still mutate the object's properties. Use Object.freeze() for true immutability.
Memory is allocated for them (so technically yes), but they sit in the Temporal Dead Zone until the declaration line. Accessing them before the line throws ReferenceError, unlike var which is hoisted with undefined.
Still have questions?
Browse all our FAQs or reach out to our support team
