QuestenaПрактика, после которой понятно, что повторить
Вопрос 89

After const rate = 3 has initialized successfully, the same scope executes rate = 4. What happens?

  1. A TypeError is thrown because the const binding is being reassignedПравильный ответ
  2. rate becomes 4 because const controls only scope
  3. A new inner rate binding is created
  4. The assignment silently leaves rate equal to 3

Объяснение

The second assignment attempts to replace the value held by a const binding, so evaluation throws a TypeError. This rule concerns rebinding the name; it should not be generalized into a claim that every object stored in const is deeply frozen.

Продолжить работу с тестом

Начать тренировку
Вопрос 89: After const rate = 3 has initialized successfully, the same… · JavaScript Fundamentals · Questena