Bindings store values. Prefer const by default, let when reassignment is required, and avoid var in modern code (function scope quirks).
Rules of thumb
const— cannot reassign the binding (object contents may still mutate)let— block-scoped reassignmentvar— legacy; hoisted function scope—avoid in new code
Block scope
let/const exist only inside { } blocks—prevents loop variable leaks.
Important interview questions and answers
- Q: const vs immutable object?
A: const blocks rebinding, not deep freeze of object properties. - Q: Why avoid var?
A: Hoisting and function scope cause subtle bugs in loops and conditionals.
Self-check
- When use let instead of const?
- What is temporal dead zone?
Tip: Default to const; use let only when reassigning.
Interview prep
- Prefer const?
Signals immutability of binding; reduces accidental reassignment.