What distinguishes `let` from `const` in JavaScript?

Study for the JavaScript Certification Test. Utilizes flashcards and multiple-choice questions; each question includes hints and explanations. Prepare to ace your exam!

The correct answer highlights a fundamental distinction between let and const in JavaScript. The key difference is that let allows for variable re-assignment, meaning that once a variable is declared using let, you can change its value later in the code. This flexibility is particularly useful when you need to update variable values based on conditions or in repeated iterations.

On the other hand, const is used to create a read-only reference to a value. Once a variable is declared with const, you cannot reassign it to a different value. It is important to note that if the constant is an object or an array, the contents of the object or the elements of the array can still be modified, but the reference itself can never be changed.

This distinction in re-assignment capabilities is the core reason why the choice accurately reflects the differences between the two variable declarations in JavaScript.

Subscribe

Get the latest from Examzify

You can unsubscribe at any time. Read our privacy policy