The primary difference is that const variables are immutable, meaning their value cannot be changed after initialization, while let variables are mutable and can be reassigne
13.
What will be logged to the console after executing the code above?
The const keyword in JavaScript ensures that variables cannot be reassigned to a new value or reference after initialization, making them constant in terms of their assigned value.
15.
What happens if you try to declare a const variable without initializing it immediately?
Declaring a const variable without initializing it immediately results in a SyntaxError because const requires initialization at the time of declaration.
16.
In JavaScript, const variables are not hoiste What does this mean?
The fact that const variables are not hoisted means they cannot be used before they are declared in the code, unlike var variables which are hoisted to the top of their scope.
The Object.freeze() method prevents modifications to an object's properties. Attempting to modify person.age after freezing person will result in a TypeError because the object is now immutable.
The true statement about const in JavaScript is that const variables cannot be reassigned after they are initialized with a value. They are constant in terms of their reference or value.
19.
What is the benefit of using const over var in JavaScript?
Using const over var in JavaScript helps prevent accidental reassignments of variables, improving code reliability and reducing the risk of unintended changes to variable values.
20.
What will happen when you try to execute this code?
Attempting to reassign a value to a constant (PI in this case) will result in a TypeError since const variables cannot be reassigned after initialization.