LOGBOOK

HELP

Quiz Entry - updated: 2026.06.20

What is the difference between let and const in JavaScript?

let declares a variable you can reassign later, while const locks the variable to its first assignment.

let a = 5;
// OK - let allows reassignment
a = 6;

const b = 5;
// ERROR - const cannot be reassigned
b = 6;

Best practice: Use const by default, only use let when you need to reassign.

Why prefer const?

  • Makes code easier to understand (value won't change)
  • Prevents accidental reassignment bugs
  • Signals intent to other developers

Note on objects:

const user = { name: 'John' };
// OK - modifying property, not reassigning
user.name = 'Jane';
// ERROR - cannot reassign the variable
user = {};

Tip: const prevents reassignment of the variable, not modification of the object it points to.

From Quiz: WEBT / Backend Development | Updated: Jun 20, 2026