Repaso
EspaƱol

In modern JavaScript, let vs const?

Options

  1. They are identical in every way in JavaScript
  2. const cannot be reassigned; let can be (Correct option)
  3. const objects cannot be modified in any way
  4. let creates a global variable in all cases

Answer

const cannot be reassigned; let can. Both are block-scoped

Why

const total = 5; means the variable total cannot point to another value later. let count = 0; count = 1; is allowed.

Both exist only inside the { } block where they are declared.

Careful: const does not freeze objects. const user = {}; user.name = "Ana"; works; only user = other is forbidden.

Rule of thumb: use const by default, let when you must reassign, and avoid var.

Remember

const by default, let when it changes, never var.

Key terms

Practice this question in Repaso