Can you reassign a new array or object to a variable declared with const?
- Yes, always
- Yes, but with restrictions
- No, it will result in an error
- Only if the variable is declared as a global constant
Variables declared with const cannot be reassigned to a new reference, whether it's an array, object, or any other data type. However, it's crucial to understand that this rule applies only to the reference itself, not the content of the variable. The content, if mutable (e.g., an object's properties), can still be modified.
Loading...
Related Quiz
- Asynchronous callbacks are placed in a queue known as the __________ queue.
- How can you import an entire module as an object in ES6?
- ________ tools are crucial in analyzing and removing unused code through tree shaking.
- What is the implication of using arrow functions in constructors?
- Tagged template literals allow you to parse template literals with a _________ function.