JavaScript Object.seal() Explained

JavaScript Logo

Object.seal() – Seals an object: prevents adding/removing properties but allows modification of existing properties.

๐Ÿ‘‰ Syntax

Object.seal(obj)

๐Ÿงช Example

const obj = { name: 'Test' };
Object.seal(obj);
obj.name = 'New'; // Allowed
obj.age = 25; // Ignored

Comments