Const Reassignment Behavior
Multiple Choice Beginner
Question
What happens when you try to reassign a const variable in JavaScript?
Hint
const creates an immutable binding.
Explanation
Reassigning a const variable throws a TypeError at runtime because const creates an immutable binding. The variable cannot be reassigned to a new value after initialization. This is enforced at runtime, not just at compile time, making const a strong guarantee that the value will not change.
Related Resources
Related Lessons
- Variables
Learn how variables work in programming.
Look up unfamiliar terms
A beginner-friendly glossary explains jargon in plain English — variables, functions, DOM, Promise, and more.
Decode error messages
Plain-English explanations of common errors — what they mean, why they happen, and how to fix them.
Build real projects
Apply what you learned by building guided projects with starter code and solutions.