Sealing an object
Sealing Objects with Object.seal()
The Object.seal()
method allows you to seal an object, preventing the addition or deletion of properties while still allowing property values to be changed.
Use Cases
Object.seal()
is useful when you want to restrict modifications to an object but still allow for property value changes. For example, consider a user profile object:
By sealing the userProfile object, you ensure that the structure remains constant, but you can update user details as needed.