Which statement is true about constant objects in JavaScript?
A). A. The properties of a constant object cannot be changed
B). B. Constant objects are frozen and immutable
C). C. Constant objects cannot have properties added or deleted
D). D. The object reference can be reassigned
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
Which of the following will cause an error when used with a constant object in JavaScript?
A). A. Modifying a property using bracket notation
B). B. Adding a property using dot notation
C). C. Deleting a property
D). D. Reassigning the object reference
How can you change the properties of a constant object in JavaScript?
A). A. Use Object.freeze()
B). B. Use const for each property
C). C. Use the delete keyword to remove properties
D). D. Use dot notation or bracket notation
How can you ensure that a constant object remains unchanged in JavaScript?
A). A. Use Object.preventExtensions()
B). B. Use Object.freeze() to freeze the object
C). C. Use const for each property
D). D. All of the above
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
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 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 will result in an error when using a constant object in JavaScript?
A). A. Modifying an existing property
B). B. Adding a new property
C). C. Reassigning the object reference
D). D. None, all operations are valid with constant objects
What happens if you try to delete a property from a constant object in JavaScript?
A). A. The property is deleted successfully
B). B. A TypeError is thrown
C). C. A SyntaxError is thrown
D). D. Nothing happens