Object.seal()
is commonly used to lock an object to prevent new properties from being added, while still allowing modifications to existing properties. It can be useful in situations where you want to ensure the structure of an object remains unchanged.
Example:
const person = { name: 'John' };
Object.seal(person);
person.name = 'Jane'; // Allowed
person.city = 'New York'; // Not allowed
Tags: basic, JavaScript, objects
URL: https://www.tiktok.com/@jsmentoring/photo/7458730878810770720