Do you know what will be the output of this code?
JavaScript
const x = 1;
x = 2;
console.log(x);
Show answer and explanation
The answer is TypeError: Assignment to constant variable.
const creates a binding that can’t be reassigned. The code throws before console.log runs. Use let when a variable needs a new value later.