What is the correct way to modify a property of a constant object in JavaScript?
A). A. Use the delete keyword
B). B. Use the const keyword for the property
C). C. Use dot notation or bracket notation to access and modify the property
D). D. Use Object.freeze() to freeze the object
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 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
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
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
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
What is the data type of a constant object in JavaScript?
A). A. Object
B). B. Array
C). C. Function
D). D. String
What is the output of the following code snippet?
A). A. { x: 10, y: 20 }
B). B. { x: 20, y: 10 }
C). C. { x: 10 }
D). D. Error
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
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