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
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
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
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
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
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
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 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 result of the expression Object.keys(person).length for the following code snippet?
A). A. 1
B). B. 2
C). C. 3
D). D. Error
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