Recall & Review
beginner
What does
const mean in JavaScript?const declares a variable that cannot be reassigned after its initial value is set.
Click to reveal answer
beginner
Can you change the value of a
const variable after it is declared?No, you cannot reassign a new value to a const variable once it is declared.
Click to reveal answer
beginner
Is it possible to declare a
const variable without initializing it?No, const variables must be initialized when declared.
Click to reveal answer
intermediate
Does
const make objects or arrays immutable?No, const prevents reassignment of the variable, but the contents of objects or arrays can still be changed.
Click to reveal answer
beginner
Example: What will happen if you run this code?<br><pre>const x = 5;<br>x = 10;</pre>This will cause an error because x is declared with const and cannot be reassigned.
Click to reveal answer
What happens if you try to reassign a
const variable?✗ Incorrect
Reassigning a const variable causes a TypeError in JavaScript.
Can you declare a
const variable without giving it a value?✗ Incorrect
const variables must be initialized when declared.
Which of these is true about
const and objects?✗ Incorrect
const prevents reassignment but object properties can be changed.
Which keyword declares a variable that cannot be reassigned?
✗ Incorrect
const declares variables that cannot be reassigned.
What will this code output?<br>
const name = 'Alice';<br>console.log(name);
✗ Incorrect
The code outputs the string 'Alice' because name is initialized with that value.
Explain how
const works for variable declaration in JavaScript.Think about what you can and cannot do after declaring with const.
You got /3 concepts.
Describe the difference between
const and let in JavaScript.Focus on reassignment and scope.
You got /3 concepts.