Programming Languages
JavaScript
Subjective
Sep 25, 2025
What is the difference between let, const, and var?
Detailed Explanation
var: Function-scoped, can be redeclared and updated, hoisted with undefined initialization.
let: Block-scoped, cannot be redeclared in same scope, can be updated, hoisted but not initialized (temporal dead zone).
const: Block-scoped, cannot be redeclared or updated, must be initialized at declaration, hoisted but not initialized.
Example:
var a = 1; // function scoped
let b = 2; // block scoped
const c = 3; // block scoped, immutable
Discussion (0)
No comments yet. Be the first to share your thoughts!
Share Your Thoughts