Q
What is the correct way to modify a property of a constant object in JavaScript?

Answer & Solution

Answer: Option C
Solution:
To modify a property of a constant object in JavaScript, you can use dot notation or bracket notation to access and modify the property.
Related Questions on Average

What is the data type of a constant object in JavaScript?

A). A. Object

B). B. Array

C). C. Function

D). D. String

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

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

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

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 statement about constant objects in JavaScript is correct?

A). A. Constant objects can have their properties reassigned

B). B. Constant objects cannot have properties added or removed

C). C. Constant objects are only applicable to primitive values

D). D. Constant objects are mutable

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

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 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 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