What happens if you try to reassign a constant object to a new object in JavaScript?
A). A. No error, the assignment is successful
B). B. TypeError is thrown
C). C. SyntaxError is thrown
D). D. ReferenceError is thrown
How can you check if an object is frozen in JavaScript?
A). A. Using the frozen property
B). B. Using the isFrozen() method
C). C. Using the Object.isFrozen() method
D). D. All of the above
What happens if you try to modify a property of a frozen object in JavaScript using Object.freeze()?
A). A. The property is modified successfully
B). B. A TypeError is thrown
C). C. The property is deleted
D). D. The object becomes mutable
Which statement best describes the behavior of a constant object in JavaScript?
A). A. The object and its properties cannot be changed
B). B. The object reference cannot be reassigned
C). C. All properties are immutable
D). D. The object cannot be modified after declaration
What is the data type of a constant object in JavaScript?
A). A. Object
B). B. Array
C). C. Function
D). D. String
What does the const keyword do when used to declare an object in JavaScript?
A). A. Makes the object immutable
B). B. Prevents reassignment of the object reference
C). C. Freezes all properties of the object
D). D. All of the above
Which of the following is a valid way to define a constant object in JavaScript?
A). A. const obj = { a: 1, b: 2 };
B). B. const obj = new Object({ a: 1, b: 2 });
C). C. Both A and B
D). D. None of the above
What happens if you use Object.freeze() on a constant object in JavaScript?
A). A. The object reference becomes mutable
B). B. The properties of the object become immutable
C). C. The object becomes frozen and cannot be modified
D). D. A TypeError is thrown
What is the output of the following code snippet?
A). A. { a: 1, b: 2, c: 3 }
B). B. { a: 1, b: 2 }
C). C. { c: 3 }
D). D. Error
How can you prevent modifications to the properties of a JavaScript object?
A). A. Use Object.preventExtensions()
B). B. Use const for each property
C). C. Use Object.freeze() to freeze the object
D). D. All of the above