Skip to content

Latest commit

 

History

History
18 lines (12 loc) · 783 Bytes

what_are_the_applications_of_seal_method.md

File metadata and controls

18 lines (12 loc) · 783 Bytes

What are the applications of seal method?

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