Object.seal()

ES5+

Seals an object, preventing new properties from being added and marking all existing properties as non-configurable.

Syntax

Object.seal(obj)

Parameters

obj Object

The object to seal

Return Value

Object

The sealed object

Examples

JavaScript
const obj = { name: 'John' };
Object.seal(obj);
obj.name = 'Jane'; // 가능
obj.age = 30; // 무시됨
console.log(obj);
Output:
// { name: 'Jane' }

Related Methods