What is the difference between var, let, and const?

Updated May 6, 2026

Short answer

var is function-scoped, while let and const are block-scoped. const cannot be reassigned.

Deep explanation

var is hoisted and can be redeclared. let and const are block-scoped and exist in the temporal dead zone until declared. const ensures binding immutability.

Real-world example

Use const for API configs, let for loop counters.

Common mistakes

  • Assuming const makes objects immutable.

Follow-up questions

  • What is hoisting?
  • Can const objects be mutated?

More JavaScript interview questions

View all →